Overwrite #kind_of? and #is_a? in Draper::Base
This commit is contained in:
parent
f42f670812
commit
7ac940f226
|
@ -175,6 +175,11 @@ module Draper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def kind_of?(klass)
|
||||||
|
model.kind_of?(klass) || super(klass)
|
||||||
|
end
|
||||||
|
alias :is_a? :kind_of?
|
||||||
|
|
||||||
def self.method_missing(method, *args, &block)
|
def self.method_missing(method, *args, &block)
|
||||||
model_class.send(method, *args, &block)
|
model_class.send(method, *args, &block)
|
||||||
end
|
end
|
||||||
|
|
|
@ -445,4 +445,24 @@ describe Draper::Base do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#kind_of?" do
|
||||||
|
context "pretends to be of kind of model class" do
|
||||||
|
it "#kind_of? Decorator" do
|
||||||
|
subject.should be_kind_of Decorator
|
||||||
|
end
|
||||||
|
|
||||||
|
it "#is_a? Decorator" do
|
||||||
|
subject.is_a?(Decorator).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "#kind_of? Product" do
|
||||||
|
subject.should be_kind_of Product
|
||||||
|
end
|
||||||
|
|
||||||
|
it "#is_a? Product" do
|
||||||
|
subject.is_a?(Product).should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue