Sha256: bf7223c70fefa6644fba4edbf8e6db5d08b366e51fbc5ab73a983f45a4aa117f

Contents?: true

Size: 769 Bytes

Versions: 21

Compression:

Stored size: 769 Bytes

Contents

class Presenter
  def initialize(subject, options = {})
    @subject = subject
    set_default_options(options)
  end

  def subject=(value)
    @subject = value
  end 
  
  def set_options(options)
    raise NotImplementedError
  end

  def set_option(option, value)
    @options[option] = value
  end

  protected
  
  def set_default_options(options)
    @options ||= {}
   
    options.each do |key,value|
      @options[key] = value unless @options.has_key?(key)
    end
  end
  
  def subject
    @subject
  end
  
  def subject=(value)
    @subject = value
  end
  
  private
  
  def method_missing(*args, &block)
    if args.is_a?(Array) && @options.has_key?(args.first)
      @options[args.first] 
    else
      @subject.send(*args, &block)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
voluntary-0.0.1 app/presenters/presenter.rb