Skip to content

Commit

Permalink
Add decorated? method
Browse files Browse the repository at this point in the history
  • Loading branch information
haines committed Oct 30, 2012
1 parent 7a32c79 commit 834a6fd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/draper/decoratable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def decorated_with?(decorator_class)
false
end

def decorated?
false
end

module ClassMethods
def decorate(options = {})
decorator_proxy = decorator_class.decorate(self.scoped, options)
Expand Down
4 changes: 4 additions & 0 deletions lib/draper/decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def decorated_with?(decorator_class)
applied_decorators.include?(decorator_class)
end

def decorated?
true
end

# Delegates == to the decorated models
#
# @return [Boolean] true if other's model == self's model
Expand Down
6 changes: 6 additions & 0 deletions spec/draper/decoratable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
end
end

describe "#decorated?" do
it "returns false" do
subject.should_not be_decorated
end
end

describe Draper::Decoratable::ClassMethods do
shared_examples_for "a call to Draper::Decoratable::ClassMethods#decorate" do
subject { klass.limit }
Expand Down
6 changes: 6 additions & 0 deletions spec/draper/decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ class CustomDecorator < Draper::Decorator
end
end

describe "#decorated?" do
it "returns true" do
subject.should be_decorated
end
end

context(".wrapped_object") do
it "return the wrapped object" do
subject.wrapped_object.should == source
Expand Down

0 comments on commit 834a6fd

Please sign in to comment.