Class: Glia::Layout
- Inherits:
-
Object
- Object
- Glia::Layout
- Defined in:
- lib/glia/layout.rb
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#handles ⇒ Object
readonly
Returns the value of attribute handles.
-
#themes ⇒ Object
readonly
Returns the value of attribute themes.
-
#update ⇒ Object
readonly
Returns the value of attribute update.
- #view_factory ⇒ Object
Instance Method Summary collapse
- #cell(name, *args) ⇒ Object
-
#initialize(area, handles, options = {}) ⇒ Layout
constructor
A new instance of Layout.
Constructor Details
#initialize(area, handles, options = {}) ⇒ Layout
Returns a new instance of Layout.
11 12 13 14 15 16 17 18 19 |
# File 'lib/glia/layout.rb', line 11 def initialize(area, handles, = {}) @area = area @themes = [:theme_inheritance] || [:default] @update = UpdateRegistry.merge_themes(area, ) @cells = {} @handles = handles @data = @update.merge(@handles) @view_factory = [:view_factory] unless [:view_factory].nil? end |
Instance Attribute Details
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
5 6 7 |
# File 'lib/glia/layout.rb', line 5 def cells @cells end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/glia/layout.rb', line 5 def data @data end |
#handles ⇒ Object (readonly)
Returns the value of attribute handles.
5 6 7 |
# File 'lib/glia/layout.rb', line 5 def handles @handles end |
#themes ⇒ Object (readonly)
Returns the value of attribute themes.
5 6 7 |
# File 'lib/glia/layout.rb', line 5 def themes @themes end |
#update ⇒ Object (readonly)
Returns the value of attribute update.
5 6 7 |
# File 'lib/glia/layout.rb', line 5 def update @update end |
#view_factory ⇒ Object
39 40 41 |
# File 'lib/glia/layout.rb', line 39 def view_factory @view_factory ||= ViewFactory.new end |
Instance Method Details
#cell(name, *args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/glia/layout.rb', line 21 def cell(name, *args) if @cells[name].nil? definition = @data[name] raise Errors::MissingCellError, "Cell #{name} is missing from layout #{@area}" if definition.nil? code = definition.delete(:class) actions = definition.delete(:actions) children = definition.delete(:children) namespace = definition.delete(:view_namespace) || Object @cells[name] = view_factory.build(code, namespace, definition, actions, *args) unless @cells[name].respond_to?(:child_definitions=) raise Errors::InvalidCellError, @cells[name].class.name+' is not a valid cell. Include Glia::Cell.' end @cells[name].child_definitions = children @cells[name].layout = self end @cells[name] end |