Sha256: ee048fe833dfd2a0160360167ce5f1800e3971745353aa1c3b5ae14306988a25

Contents?: true

Size: 719 Bytes

Versions: 25

Compression:

Stored size: 719 Bytes

Contents

class Refinery::BasePresenter

  DEFAULT_FIELDS = {
    :title              => Proc.new { |p| p.model.present? ? p.model.class.name.titleize : nil },
    :path               => Proc.new { |p| p.title },
    :browser_title      => nil,
    :meta_description   => nil,
    :meta_keywords      => nil
  }

  attr_reader :model

  def initialize(obj)
    @model = obj
  end

  def method_missing(method, *args)
    if @model.respond_to? method
      @model.send method
    elsif DEFAULT_FIELDS.has_key? method
      (value = DEFAULT_FIELDS[method]).is_a?(Proc) ? value.call(self) : value
    else
      raise NoMethodError.new("#{self.class.name} doesn't know #{method}. Define or delegate it.", method)
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
refinerycms-0.9.8.9 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.8 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.7 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.6 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.7.15 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.14 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.8.5 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.4 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.3 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.2 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8.1 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.8 vendor/refinerycms/core/lib/refinery/base_presenter.rb
refinerycms-0.9.7.13 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.11 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.10 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.9 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.8 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.7 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.6 vendor/plugins/refinery/lib/refinery/base_presenter.rb
refinerycms-0.9.7.5 vendor/plugins/refinery/lib/refinery/base_presenter.rb