Skip to content

Commit

Permalink
Allow inheritance in decent configurations
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
Ingemar Edsborn and Joshua Davey authored and hashrocketeer committed Jul 30, 2012
1 parent 7726119 commit 7875f50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/decent_exposure/expose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module DecentExposure
module Expose
def self.extended(base)
base.class_eval do
class_attribute :_default_exposure
class_attribute :_default_exposure, :_decent_configurations
self._decent_configurations ||= Hash.new(Configuration.new)

def _resources
@_resources ||= {}
end
Expand All @@ -17,10 +19,6 @@ def _exposures
@_exposures ||= {}
end

def _decent_configurations
@_decent_configurations ||= Hash.new(Configuration.new)
end

def decent_configuration(name=:default,&block)
_decent_configurations[name] = Configuration.new(&block)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/controllers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class DuckController < BirdController
expose(:bird) { "Duck" }
expose(:ducks) { DuckCollection.new }
expose(:duck)

expose(:custom_from_config, :config => :custom)
end

class MallardController < DuckController; end
Expand Down
4 changes: 4 additions & 0 deletions spec/rails_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
it "allows overriding exposures" do
controller.bird.should == "Duck"
end

it "inherits decent configurations" do
controller.custom_from_config.should == "custom_from_configshow"
end
end

describe "collection scope" do
Expand Down

0 comments on commit 7875f50

Please sign in to comment.