Added .source / .to_source both to Base and DecoratedEnumerableProxy.
This commit is contained in:
parent
d154059572
commit
1af010c105
|
@ -225,7 +225,13 @@ module Draper
|
|||
options[:context] = input
|
||||
end
|
||||
|
||||
def source
|
||||
model
|
||||
end
|
||||
alias_method :to_source, :model
|
||||
|
||||
private
|
||||
|
||||
def allow?(method)
|
||||
(!allowed? || allowed.include?(method) || FORCED_PROXY.include?(method)) && !denied.include?(method)
|
||||
end
|
||||
|
|
|
@ -38,5 +38,10 @@ module Draper
|
|||
def to_s
|
||||
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
|
||||
end
|
||||
|
||||
def source
|
||||
@wrapped_collection
|
||||
end
|
||||
alias_method :to_source, :source
|
||||
end
|
||||
end
|
||||
|
|
|
@ -119,6 +119,13 @@ describe Draper::Base do
|
|||
end
|
||||
end
|
||||
|
||||
context(".source / .to_source") do
|
||||
it "should return the wrapped object" do
|
||||
subject.to_source == source
|
||||
subject.source == source
|
||||
end
|
||||
end
|
||||
|
||||
context("selecting methods") do
|
||||
it "echos the methods of the wrapped class except default exclusions" do
|
||||
source.methods.each do |method|
|
||||
|
@ -438,6 +445,13 @@ describe Draper::Base do
|
|||
collection.first.context.should == :admin
|
||||
end
|
||||
end
|
||||
|
||||
context(".source / .to_source") do
|
||||
it "should return the wrapped object" do
|
||||
subject.to_source == source
|
||||
subject.source == source
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "a sample usage with denies" do
|
||||
|
|
Loading…
Reference in New Issue