class Argyle::Page::Base

@!attribute [r] components

@return [Hash{Symbol=>Argyle::Component::Base}]

@!attribute [r] layout

@return [Argyle::Layout::Base]

@!attribute [r] identifier

@return [Symbol]

Attributes

component_prototypes[R]
identifier[R]
layout_id[R]
components[R]
layout[R]

Public Class Methods

new(components, layout) click to toggle source
# File lib/argyle/page/base.rb, line 13
def initialize(components, layout)
  @components = components
  @layout = layout
end

Private Class Methods

area(id) { || ... } click to toggle source

@param id [Symbol]

@raise [Argyle::Error::RuntimeError] When area calls are nested

# File lib/argyle/page/base.rb, line 49
def area(id)
  raise Argyle::Error::RuntimeError.new('Areas cannot be nested') unless @current_area == :main

  @current_area = id
  yield
  @current_area = :main
end
id(id) click to toggle source

@param id [Symbol]

# File lib/argyle/page/base.rb, line 34
def id(id)
  @identifier = id
end
inherited(klass) click to toggle source
Calls superclass method
# File lib/argyle/page/base.rb, line 63
def inherited(klass)
  super

  klass.instance_variable_set('@identifier', nil)
  klass.instance_variable_set('@current_area', :main)

  klass.instance_variable_set('@component_prototypes', component_prototypes || {})
  klass.instance_variable_set('@layout_id', layout_id)
end
layout(id) click to toggle source

@param id [Symbol]

# File lib/argyle/page/base.rb, line 59
def layout(id)
  @layout_id = id
end
text(id, value) click to toggle source

@param id [Symbol] @param value [String]

# File lib/argyle/page/base.rb, line 41
def text(id, value)
  component_prototypes[id] = Argyle::Prototype.new(Argyle::Component::Text, {value: value, area: @current_area})
end