Sha256: d0eea8a91c328379d9e35c60e9caf3a7072d68a7a15b6ffb718fc3074fc00257

Contents?: true

Size: 851 Bytes

Versions: 13

Compression:

Stored size: 851 Bytes

Contents

require "./performance/models"
class ProductDecorator < Draper::Base
  decorates :product

  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::Base
  decorates :product

  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

13 entries across 13 versions & 1 rubygems

Version Path
draper-0.18.0 performance/decorators.rb
draper-0.17.0 performance/decorators.rb
draper-0.16.0 performance/decorators.rb
draper-0.15.0 performance/decorators.rb
draper-0.15.0rc1 performance/decorators.rb
draper-0.14.0 performance/decorators.rb
draper-0.12.3 performance/decorators.rb
draper-0.12.2 performance/decorators.rb
draper-0.13.0 performance/decorators.rb
draper-0.12.1 performance/decorators.rb
draper-0.12.0 performance/decorators.rb
draper-0.11.1 performance/decorators.rb
draper-0.11.0 performance/decorators.rb