Sha256: 9d26088b972f164c43e47173a7f8b16890cb606d383ca2fd365a531669837696

Contents?: true

Size: 819 Bytes

Versions: 27

Compression:

Stored size: 819 Bytes

Contents

require "./performance/models"
class ProductDecorator < Draper::Decorator

  def awesome_title
    "Awesome Title"
  end

  # Original #method_missing
  def method_missing(method, *args, &block)
    if allow?(method)
      begin
        model.send(method, *args, &block)
      rescue NoMethodError
        super
      end
    else
      super
    end
  end

end

class FastProductDecorator < Draper::Decorator

  def awesome_title
    "Awesome Title"
  end

  # Modified #method_missing
  def method_missing(method, *args, &block)
    if allow?(method)
      begin
        self.class.send :define_method, method do |*args, &block|
          model.send(method, *args, &block)
        end
        self.send(method, *args, &block)
      rescue NoMethodError
        super
      end
    else
      super
    end
  end

end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
draper-4.0.4 spec/performance/decorators.rb
draper-4.0.3 spec/performance/decorators.rb
draper-4.0.2 spec/performance/decorators.rb
draper-4.0.1 spec/performance/decorators.rb
draper-4.0.0 spec/performance/decorators.rb
draper-3.1.0 spec/performance/decorators.rb
draper-3.0.1 spec/performance/decorators.rb
draper-3.0.0 spec/performance/decorators.rb
draper-3.0.0.pre1 spec/performance/decorators.rb
draper_new-3.0.0 spec/performance/decorators.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/draper-2.1.0/spec/performance/decorators.rb
draper-2.1.0 spec/performance/decorators.rb
draper-2.0.0 spec/performance/decorators.rb
draper-1.4.0 spec/performance/decorators.rb
draper-1.3.1 spec/performance/decorators.rb
draper-1.3.0 spec/performance/decorators.rb
draper-1.2.1 spec/performance/decorators.rb
draper-1.2.0 spec/performance/decorators.rb
jamesgolick-draper-1.1.1a spec/performance/decorators.rb
draper-1.1.0 spec/performance/decorators.rb