Automatically create a named accessor method for the wrapped model
This commit is contained in:
parent
19f1fc7b69
commit
5cb6f7210a
|
@ -51,6 +51,7 @@ module Draper
|
||||||
def self.decorates(input)
|
def self.decorates(input)
|
||||||
self.model_class = input.to_s.camelize.constantize
|
self.model_class = input.to_s.camelize.constantize
|
||||||
model_class.send :include, Draper::ModelSupport
|
model_class.send :include, Draper::ModelSupport
|
||||||
|
define_method(input){ @model }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Specifies a black list of methods which may *not* be proxied to
|
# Specifies a black list of methods which may *not* be proxied to
|
||||||
|
|
|
@ -40,6 +40,11 @@ describe Draper::Base do
|
||||||
BusinessDecorator.model_class.should == Business
|
BusinessDecorator.model_class.should == Business
|
||||||
end.should_not raise_error
|
end.should_not raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "creates a named accessor for the wrapped model" do
|
||||||
|
pd = ProductDecorator.new(source)
|
||||||
|
pd.send(:product).should == source
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context(".model / .to_model") do
|
context(".model / .to_model") do
|
||||||
|
|
Loading…
Reference in New Issue