Merge pull request #333 from haines/method_missing
Refactor Decorator#method_missing
This commit is contained in:
commit
33808da454
|
@ -157,21 +157,12 @@ module Draper
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(method, *args, &block)
|
def method_missing(method, *args, &block)
|
||||||
super unless allow?(method)
|
if allow?(method) && source.respond_to?(method)
|
||||||
|
self.class.define_proxy(method)
|
||||||
if source.respond_to?(method)
|
send(method, *args, &block)
|
||||||
self.class.send :define_method, method do |*args, &blokk|
|
|
||||||
source.send method, *args, &blokk
|
|
||||||
end
|
|
||||||
|
|
||||||
send method, *args, &block
|
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue NoMethodError => no_method_error
|
|
||||||
super if no_method_error.name == method
|
|
||||||
raise no_method_error
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# For ActiveModel compatibilty
|
# For ActiveModel compatibilty
|
||||||
|
@ -186,6 +177,12 @@ module Draper
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def self.define_proxy(method)
|
||||||
|
define_method(method) do |*args, &block|
|
||||||
|
source.send(method, *args, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.security
|
def self.security
|
||||||
@security ||= Security.new
|
@security ||= Security.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -136,11 +136,11 @@ describe Draper::CollectionDecorator do
|
||||||
|
|
||||||
describe ".helpers" do
|
describe ".helpers" do
|
||||||
it "returns a HelperProxy" do
|
it "returns a HelperProxy" do
|
||||||
Decorator.helpers.should be_a Draper::HelperProxy
|
subject.class.helpers.should be_a Draper::HelperProxy
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is aliased to .h" do
|
it "is aliased to .h" do
|
||||||
Decorator.h.should be Decorator.helpers
|
subject.class.h.should be subject.class.helpers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Draper::Decorator do
|
describe Draper::Decorator do
|
||||||
before { ApplicationController.new.view_context }
|
before { ApplicationController.new.view_context }
|
||||||
subject { Decorator.new(source) }
|
subject { decorator_class.new(source) }
|
||||||
|
let(:decorator_class) { Draper::Decorator }
|
||||||
let(:source) { Product.new }
|
let(:source) { Product.new }
|
||||||
let(:non_active_model_source){ NonActiveModelProduct.new }
|
|
||||||
|
|
||||||
describe "#initialize" do
|
describe "#initialize" do
|
||||||
it "sets the source" do
|
it "sets the source" do
|
||||||
|
@ -12,7 +12,7 @@ describe Draper::Decorator do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "stores options" do
|
it "stores options" do
|
||||||
decorator = Decorator.new(source, some: "options")
|
decorator = decorator_class.new(source, some: "options")
|
||||||
decorator.options.should == {some: "options"}
|
decorator.options.should == {some: "options"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ describe Draper::Decorator do
|
||||||
describe "#localize" do
|
describe "#localize" do
|
||||||
before { subject.helpers.should_receive(:localize).with(:an_object, {some: "options"}) }
|
before { subject.helpers.should_receive(:localize).with(:an_object, {some: "options"}) }
|
||||||
|
|
||||||
it "delegates to helpers" do
|
it "delegates to #helpers" do
|
||||||
subject.localize(:an_object, some: "options")
|
subject.localize(:an_object, some: "options")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -117,16 +117,17 @@ describe Draper::Decorator do
|
||||||
|
|
||||||
describe ".helpers" do
|
describe ".helpers" do
|
||||||
it "returns a HelperProxy" do
|
it "returns a HelperProxy" do
|
||||||
Decorator.helpers.should be_a Draper::HelperProxy
|
subject.class.helpers.should be_a Draper::HelperProxy
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is aliased to .h" do
|
it "is aliased to .h" do
|
||||||
Decorator.h.should be Decorator.helpers
|
subject.class.h.should be subject.class.helpers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".decorates_association" do
|
describe ".decorates_association" do
|
||||||
before { subject.class.decorates_association :similar_products, with: ProductDecorator }
|
let(:decorator_class) { Class.new(ProductDecorator) }
|
||||||
|
before { decorator_class.decorates_association :similar_products, with: ProductDecorator }
|
||||||
|
|
||||||
describe "overridden association method" do
|
describe "overridden association method" do
|
||||||
let(:decorated_association) { ->{} }
|
let(:decorated_association) { ->{} }
|
||||||
|
@ -151,7 +152,7 @@ describe Draper::Decorator do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".decorates_associations" do
|
describe ".decorates_associations" do
|
||||||
subject { Decorator }
|
subject { decorator_class }
|
||||||
|
|
||||||
it "decorates each of the associations" do
|
it "decorates each of the associations" do
|
||||||
subject.should_receive(:decorates_association).with(:similar_products, {})
|
subject.should_receive(:decorates_association).with(:similar_products, {})
|
||||||
|
@ -210,58 +211,13 @@ describe Draper::Decorator do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "method selection" do
|
describe "#to_param" do
|
||||||
it "echos the methods of the wrapped class" do
|
it "proxies to the source" do
|
||||||
source.methods.each do |method|
|
source.stub(:to_param).and_return(42)
|
||||||
subject.respond_to?(method.to_sym, true).should be_true
|
subject.to_param.should == 42
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "not override a defined method with a source method" do
|
|
||||||
DecoratorWithApplicationHelper.new(source).length.should == "overridden"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "not copy the .class, .inspect, or other existing methods" do
|
|
||||||
source.class.should_not == subject.class
|
|
||||||
source.inspect.should_not == subject.inspect
|
|
||||||
source.to_s.should_not == subject.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when an ActiveModel descendant" do
|
|
||||||
it "always proxy to_param if it is not defined on the decorator itself" do
|
|
||||||
source.stub(:to_param).and_return(1)
|
|
||||||
Draper::Decorator.new(source).to_param.should == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
it "always proxy id if it is not defined on the decorator itself" do
|
|
||||||
source.stub(:id).and_return(123456789)
|
|
||||||
Draper::Decorator.new(source).id.should == 123456789
|
|
||||||
end
|
|
||||||
|
|
||||||
it "always proxy errors if it is not defined on the decorator itself" do
|
|
||||||
Draper::Decorator.new(source).errors.should be_an_instance_of ActiveModel::Errors
|
|
||||||
end
|
|
||||||
|
|
||||||
it "never proxy to_param if it is defined on the decorator itself" do
|
|
||||||
source.stub(:to_param).and_return(1)
|
|
||||||
DecoratorWithSpecialMethods.new(source).to_param.should == "foo"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "never proxy id if it is defined on the decorator itself" do
|
|
||||||
source.stub(:id).and_return(123456789)
|
|
||||||
DecoratorWithSpecialMethods.new(source).id.should == 1337
|
|
||||||
end
|
|
||||||
|
|
||||||
it "never proxy errors if it is defined on the decorator itself" do
|
|
||||||
DecoratorWithSpecialMethods.new(source).errors.should be_an_instance_of Array
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "wrap source methods so they still accept blocks" do
|
|
||||||
subject.block{"marker"}.should == "marker"
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#==" do
|
describe "#==" do
|
||||||
it "compares the decorated models" do
|
it "compares the decorated models" do
|
||||||
other = Draper::Decorator.new(source)
|
other = Draper::Decorator.new(source)
|
||||||
|
@ -270,13 +226,104 @@ describe Draper::Decorator do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#respond_to?" do
|
describe "#respond_to?" do
|
||||||
# respond_to? is called by some proxies (id, to_param, errors).
|
let(:decorator_class) { Class.new(ProductDecorator) }
|
||||||
# This is, why I stub it this way.
|
|
||||||
it "delegates to the decorated model" do
|
it "returns true for its own methods" do
|
||||||
other = Draper::Decorator.new(source)
|
subject.should respond_to :awesome_title
|
||||||
source.stub(:respond_to?).and_return(false)
|
end
|
||||||
source.should_receive(:respond_to?).with(:whatever, true).once.and_return("mocked")
|
|
||||||
subject.respond_to?(:whatever, true).should == "mocked"
|
it "returns true for the source's methods" do
|
||||||
|
subject.should respond_to :title
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with include_private" do
|
||||||
|
it "returns true for its own private methods" do
|
||||||
|
subject.respond_to?(:awesome_private_title, true).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns true for the source's private methods" do
|
||||||
|
subject.respond_to?(:private_title, true).should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with method security" do
|
||||||
|
it "respects allows" do
|
||||||
|
subject.class.allows :hello_world
|
||||||
|
|
||||||
|
subject.should respond_to :hello_world
|
||||||
|
subject.should_not respond_to :goodnight_moon
|
||||||
|
end
|
||||||
|
|
||||||
|
it "respects denies" do
|
||||||
|
subject.class.denies :goodnight_moon
|
||||||
|
|
||||||
|
subject.should respond_to :hello_world
|
||||||
|
subject.should_not respond_to :goodnight_moon
|
||||||
|
end
|
||||||
|
|
||||||
|
it "respects denies_all" do
|
||||||
|
subject.class.denies_all
|
||||||
|
|
||||||
|
subject.should_not respond_to :hello_world
|
||||||
|
subject.should_not respond_to :goodnight_moon
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "method proxying" do
|
||||||
|
let(:decorator_class) { Class.new(ProductDecorator) }
|
||||||
|
|
||||||
|
it "does not proxy methods that are defined on the decorator" do
|
||||||
|
subject.overridable.should be :overridden
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not proxy methods inherited from Object" do
|
||||||
|
subject.inspect.should_not be source.inspect
|
||||||
|
end
|
||||||
|
|
||||||
|
it "proxies missing methods that exist on the source" do
|
||||||
|
source.stub(:hello_world).and_return(:proxied)
|
||||||
|
subject.hello_world.should be :proxied
|
||||||
|
end
|
||||||
|
|
||||||
|
it "adds proxied methods to the decorator when they are used" do
|
||||||
|
subject.methods.should_not include :hello_world
|
||||||
|
subject.hello_world
|
||||||
|
subject.methods.should include :hello_world
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes blocks to proxied methods" do
|
||||||
|
subject.block{"marker"}.should == "marker"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not confuse Kernel#Array" do
|
||||||
|
Array(subject).should be_a Array
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with method security" do
|
||||||
|
it "respects allows" do
|
||||||
|
source.stub(:hello_world, :goodnight_moon).and_return(:proxied)
|
||||||
|
subject.class.allows :hello_world
|
||||||
|
|
||||||
|
subject.hello_world.should be :proxied
|
||||||
|
expect{subject.goodnight_moon}.to raise_error NameError
|
||||||
|
end
|
||||||
|
|
||||||
|
it "respects denies" do
|
||||||
|
source.stub(:hello_world, :goodnight_moon).and_return(:proxied)
|
||||||
|
subject.class.denies :goodnight_moon
|
||||||
|
|
||||||
|
subject.hello_world.should be :proxied
|
||||||
|
expect{subject.goodnight_moon}.to raise_error NameError
|
||||||
|
end
|
||||||
|
|
||||||
|
it "respects denies_all" do
|
||||||
|
source.stub(:hello_world, :goodnight_moon).and_return(:proxied)
|
||||||
|
subject.class.denies_all
|
||||||
|
|
||||||
|
expect{subject.hello_world}.to raise_error NameError
|
||||||
|
expect{subject.goodnight_moon}.to raise_error NameError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -302,64 +349,26 @@ describe Draper::Decorator do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "in a Rails application" do
|
context "in a Rails application" do
|
||||||
let(:decorator){ DecoratorWithApplicationHelper.decorate(Object.new) }
|
let(:decorator_class) { DecoratorWithApplicationHelper }
|
||||||
|
|
||||||
it "has access to ApplicationHelper helpers" do
|
it "has access to ApplicationHelper helpers" do
|
||||||
decorator.uses_hello_world.should == "Hello, World!"
|
subject.uses_hello_world.should == "Hello, World!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to use the content_tag helper" do
|
it "is able to use the content_tag helper" do
|
||||||
decorator.sample_content.to_s.should == "<span>Hello, World!</span>"
|
subject.sample_content.to_s.should == "<span>Hello, World!</span>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to use the link_to helper" do
|
it "is able to use the link_to helper" do
|
||||||
decorator.sample_link.should == "<a href=\"/World\">Hello</a>"
|
subject.sample_link.should == "<a href=\"/World\">Hello</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to use the pluralize helper" do
|
it "is able to use the truncate helper" do
|
||||||
decorator.sample_truncate.should == "Once..."
|
subject.sample_truncate.should == "Once..."
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is able to access html_escape, a private method" do
|
it "is able to access html_escape, a private method" do
|
||||||
decorator.sample_html_escaped_text.should == '<script>danger</script>'
|
subject.sample_html_escaped_text.should == '<script>danger</script>'
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#method_missing" do
|
|
||||||
context "with an isolated decorator class" do
|
|
||||||
let(:decorator_class) { Class.new(Decorator) }
|
|
||||||
subject{ decorator_class.new(source) }
|
|
||||||
|
|
||||||
context "when #hello_world is called again" do
|
|
||||||
it "proxies method directly after first hit" do
|
|
||||||
subject.methods.should_not include(:hello_world)
|
|
||||||
subject.hello_world
|
|
||||||
subject.methods.should include(:hello_world)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when #hello_world is called for the first time" do
|
|
||||||
it "hits method missing" do
|
|
||||||
subject.should_receive(:method_missing)
|
|
||||||
subject.hello_world
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the delegated method calls a non-existant method" do
|
|
||||||
it "should not try to delegate to non-existant methods to not confuse Kernel#Array" do
|
|
||||||
Array(subject).should be_kind_of(Array)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "raises the correct NoMethodError" do
|
|
||||||
begin
|
|
||||||
subject.some_action
|
|
||||||
rescue NoMethodError => e
|
|
||||||
e.name.should_not == :some_action
|
|
||||||
else
|
|
||||||
fail("No exception raised")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -390,24 +399,28 @@ describe Draper::Decorator do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with for: symbol" do
|
context "with :for option" do
|
||||||
|
subject { Class.new(Draper::Decorator) }
|
||||||
|
|
||||||
|
context "with a symbol" do
|
||||||
it "sets the finder class" do
|
it "sets the finder class" do
|
||||||
FinderDecorator.has_finders for: :product
|
subject.has_finders for: :product
|
||||||
FinderDecorator.finder_class.should be Product
|
subject.finder_class.should be Product
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with for: string" do
|
context "with a string" do
|
||||||
it "sets the finder class" do
|
it "sets the finder class" do
|
||||||
FinderDecorator.has_finders for: "some_thing"
|
subject.has_finders for: "some_thing"
|
||||||
FinderDecorator.finder_class.should be SomeThing
|
subject.finder_class.should be SomeThing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with for: class" do
|
context "with a class" do
|
||||||
it "sets the finder_class" do
|
it "sets the finder_class" do
|
||||||
FinderDecorator.has_finders for: Namespace::Product
|
subject.has_finders for: Namespace::Product
|
||||||
FinderDecorator.finder_class.should be Namespace::Product
|
subject.finder_class.should be Namespace::Product
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,49 +3,29 @@ require 'ammeter/init'
|
||||||
require 'rails'
|
require 'rails'
|
||||||
|
|
||||||
require 'action_view'
|
require 'action_view'
|
||||||
Bundler.require
|
|
||||||
|
|
||||||
require './spec/support/samples/active_record'
|
|
||||||
require './spec/support/samples/decorator'
|
|
||||||
require './spec/support/samples/decorator_with_application_helper'
|
|
||||||
require './spec/support/samples/decorator_with_special_methods'
|
|
||||||
require './spec/support/samples/finder_decorator'
|
|
||||||
require './spec/support/samples/namespaced_product'
|
|
||||||
require './spec/support/samples/namespaced_product_decorator'
|
|
||||||
require './spec/support/samples/non_active_model_product'
|
|
||||||
require './spec/support/samples/non_active_model_product_decorator'
|
|
||||||
require './spec/support/samples/product'
|
|
||||||
require './spec/support/samples/product_decorator'
|
|
||||||
require './spec/support/samples/products_decorator'
|
|
||||||
require './spec/support/samples/sequel_product'
|
|
||||||
require './spec/support/samples/specific_product_decorator'
|
|
||||||
require './spec/support/samples/some_thing'
|
|
||||||
require './spec/support/samples/some_thing_decorator'
|
|
||||||
require './spec/support/samples/uninferrable_decorator_model'
|
|
||||||
require './spec/support/samples/widget'
|
|
||||||
require './spec/support/samples/widget_decorator'
|
|
||||||
|
|
||||||
require 'action_controller'
|
require 'action_controller'
|
||||||
require 'action_controller/test_case'
|
require 'action_controller/test_case'
|
||||||
|
|
||||||
module ActionController
|
Bundler.require
|
||||||
class Base
|
|
||||||
Draper::System.setup_action_controller(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module ActiveRecord
|
require './spec/support/active_record'
|
||||||
class Relation
|
require './spec/support/action_controller'
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
require './spec/support/models/product'
|
||||||
def hello_world
|
require './spec/support/models/namespaced_product'
|
||||||
"Hello, World!"
|
require './spec/support/models/non_active_model_product'
|
||||||
end
|
require './spec/support/models/widget'
|
||||||
helper_method :hello_world
|
require './spec/support/models/some_thing'
|
||||||
end
|
require './spec/support/models/uninferrable_decorator_model'
|
||||||
|
|
||||||
|
require './spec/support/decorators/product_decorator'
|
||||||
|
require './spec/support/decorators/namespaced_product_decorator'
|
||||||
|
require './spec/support/decorators/non_active_model_product_decorator'
|
||||||
|
require './spec/support/decorators/widget_decorator'
|
||||||
|
require './spec/support/decorators/specific_product_decorator'
|
||||||
|
require './spec/support/decorators/products_decorator'
|
||||||
|
require './spec/support/decorators/some_thing_decorator'
|
||||||
|
require './spec/support/decorators/decorator_with_application_helper'
|
||||||
|
|
||||||
class << Rails
|
class << Rails
|
||||||
undef application # Avoid silly Rails bug: https://github.com/rails/rails/pull/6429
|
undef application # Avoid silly Rails bug: https://github.com/rails/rails/pull/6429
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
module ActionController
|
||||||
|
class Base
|
||||||
|
Draper::System.setup_action_controller(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ApplicationController < ActionController::Base
|
||||||
|
def hello_world
|
||||||
|
"Hello, World!"
|
||||||
|
end
|
||||||
|
helper_method :hello_world
|
||||||
|
end
|
|
@ -15,3 +15,8 @@ module ActiveRecord
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module ActiveRecord
|
||||||
|
class Relation
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,3 @@
|
||||||
require './spec/support/samples/namespaced_product'
|
|
||||||
|
|
||||||
module Namespace
|
module Namespace
|
||||||
class ProductDecorator < Draper::Decorator
|
class ProductDecorator < Draper::Decorator
|
||||||
has_finders
|
has_finders
|
|
@ -5,6 +5,15 @@ class ProductDecorator < Draper::Decorator
|
||||||
"Awesome Title"
|
"Awesome Title"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def overridable
|
||||||
|
:overridden
|
||||||
|
end
|
||||||
|
|
||||||
def self.my_class_method
|
def self.my_class_method
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def awesome_private_title
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,2 @@
|
||||||
require './spec/support/samples/product_decorator'
|
|
||||||
|
|
||||||
class SpecificProductDecorator < ProductDecorator
|
class SpecificProductDecorator < ProductDecorator
|
||||||
end
|
end
|
|
@ -1,5 +1,3 @@
|
||||||
require './spec/support/samples/product'
|
|
||||||
|
|
||||||
module Namespace
|
module Namespace
|
||||||
class Product < ActiveRecord::Base
|
class Product < ActiveRecord::Base
|
||||||
include Draper::Decoratable
|
include Draper::Decoratable
|
|
@ -77,4 +77,12 @@ class Product < ActiveRecord::Base
|
||||||
Product.new
|
Product.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def overridable
|
||||||
|
:overridable
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def private_title
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,5 +0,0 @@
|
||||||
class Decorator < Draper::Decorator
|
|
||||||
def self.own_class_method
|
|
||||||
"own class method"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
class DecoratorWithSpecialMethods < Draper::Decorator
|
|
||||||
def to_param
|
|
||||||
"foo"
|
|
||||||
end
|
|
||||||
|
|
||||||
def id
|
|
||||||
1337
|
|
||||||
end
|
|
||||||
|
|
||||||
def errors
|
|
||||||
["omg errors!"]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,2 +0,0 @@
|
||||||
class FinderDecorator < Draper::Decorator
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
module Sequel
|
|
||||||
class Model
|
|
||||||
def each
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class SequelProduct < Sequel::Model
|
|
||||||
def some_attribute
|
|
||||||
"hello"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue