Class: TypeStation::DSL::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/type_station/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, options = {}, parent = nil) ⇒ Page

Returns a new instance of Page.



10
11
12
13
14
15
# File 'lib/type_station/dsl.rb', line 10

def initialize(title, options = {}, parent = nil)
  @title = title
  @options = options
  @parent = parent
  @model = _build_model(@title, @options, @parent)
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



9
10
11
# File 'lib/type_station/dsl.rb', line 9

def model
  @model
end

Instance Method Details

#call(&block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/type_station/dsl.rb', line 17

def call(&block)
  if block_given?
    if block.arity == 1
      block.call model
    else
      instance_eval &block
    end
  end
  model
end

#page(name, options = {}, &block) ⇒ Object



28
29
30
# File 'lib/type_station/dsl.rb', line 28

def page(name, options = {}, &block)
  Page.new(name, options, model).call(&block)
end