Sha256: fe74395c828bb83f824a52af0034b6927b3123b9f77c02ca48982ede7385d157

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 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

  class << self
    attr_accessor :template

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

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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
base_presenter-0.0.7 lib/base_presenter.rb
base_presenter-0.0.6 lib/base_presenter.rb