Sha256: 51d341a438fac2f4dfe6f401ebac5fec9ed70adab9c13c15d953a6e203fc6848

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

require "base_presenter/version"
require "application_helper"

class BasePresenter

  def initialize(object, template)
    @object = object
    @template = template
  end

  def method_missing(*args, &block)
    @template.send(*args, &block)
  end

  # Return span with 'None given' when value is blank
  def handle_none(value)
    if value.present?
      yield
    else
      content_tag :span, "None given", class: "none"
    end
  end

  def self.initialize(object, template)
    @@object = object
    @@template = template
  end

  def self.presents(name)
    define_method(name) do
      @object
    end
  end

  def self.method_missing(*args, &block)
    @@template.send(*args, &block)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
base_presenter-0.0.9 lib/base_presenter.rb
base_presenter-0.0.8 lib/base_presenter.rb