Sha256: c049db89caf140dc4d60a52c7763081aaed7f566a5fa4498522471cb2ac1dcdf

Contents?: true

Size: 511 Bytes

Versions: 10

Compression:

Stored size: 511 Bytes

Contents

module Draper::ModelSupport
  extend ActiveSupport::Concern

  def decorator(options = {})
    @decorator ||= "#{self.class.name}Decorator".constantize.decorate(self, options.merge(:infer => false))
    block_given? ? yield(@decorator) : @decorator
  end

  alias :decorate :decorator

  module ClassMethods
    def decorate(options = {})
      decorator_proxy = "#{model_name}Decorator".constantize.decorate(self.scoped, options)
      block_given? ? yield(decorator_proxy) : decorator_proxy
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
draper-0.17.0 lib/draper/model_support.rb
draper-0.16.0 lib/draper/model_support.rb
draper-0.15.0 lib/draper/model_support.rb
draper-0.15.0rc1 lib/draper/model_support.rb
draper-0.14.0 lib/draper/model_support.rb
draper-0.12.3 lib/draper/model_support.rb
draper-0.12.2 lib/draper/model_support.rb
draper-0.13.0 lib/draper/model_support.rb
draper-0.12.1 lib/draper/model_support.rb
draper-0.12.0 lib/draper/model_support.rb