Class: Sunrise::Config::PagePresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/sunrise/config/page_presenter.rb

Overview

A simple object that gets used to present different aspects of views

Initialize with a set of options and a block. The options become available using hash style syntax.

Usage:

presenter = PagePresenter.new as: :table do
  # some awesome stuff
end

presenter[:as]    #=> :table
presenter.block   #=> The block passed in to new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ PagePresenter

Returns a new instance of PagePresenter.



22
23
24
# File 'lib/sunrise/config/page_presenter.rb', line 22

def initialize(options = {}, &block)
  @options, @block = options, block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



18
19
20
# File 'lib/sunrise/config/page_presenter.rb', line 18

def block
  @block
end

#optionsObject (readonly)

Returns the value of attribute options.



18
19
20
# File 'lib/sunrise/config/page_presenter.rb', line 18

def options
  @options
end

Instance Method Details

#[](key) ⇒ Object



26
27
28
# File 'lib/sunrise/config/page_presenter.rb', line 26

def [](key)
  @options[key]
end