Class: Argyle::Page::Base
- Inherits:
-
Object
- Object
- Argyle::Page::Base
- Defined in:
- lib/argyle/page/base.rb
Class Attribute Summary collapse
-
.component_prototypes ⇒ Object
readonly
Returns the value of attribute component_prototypes.
-
.identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
.layout_id ⇒ Object
readonly
Returns the value of attribute layout_id.
Instance Attribute Summary collapse
- #components ⇒ Hash{Symbol=>Argyle::Component::Base} readonly
- #identifier ⇒ Symbol readonly
- #layout ⇒ Argyle::Layout::Base readonly
Instance Method Summary collapse
-
#initialize(components, layout) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(components, layout) ⇒ Base
Returns a new instance of Base.
13 14 15 16 |
# File 'lib/argyle/page/base.rb', line 13 def initialize(components, layout) @components = components @layout = layout end |
Class Attribute Details
.component_prototypes ⇒ Object (readonly)
Returns the value of attribute component_prototypes.
28 29 30 |
# File 'lib/argyle/page/base.rb', line 28 def component_prototypes @component_prototypes end |
.identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
28 29 30 |
# File 'lib/argyle/page/base.rb', line 28 def identifier @identifier end |
.layout_id ⇒ Object (readonly)
Returns the value of attribute layout_id.
28 29 30 |
# File 'lib/argyle/page/base.rb', line 28 def layout_id @layout_id end |
Instance Attribute Details
#components ⇒ Hash{Symbol=>Argyle::Component::Base} (readonly)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/argyle/page/base.rb', line 10 class Argyle::Page::Base attr_reader :components, :layout def initialize(components, layout) @components = components @layout = layout end # @!attribute [r] component_prototypes # @return [Hash{Symbol=>Argyle::Prototype}] # # @!attribute [r] layout_id # @return [Symbol] # # @!attribute [r] id # @return [Symbol] # class << self attr_reader :component_prototypes, :layout_id, :identifier private # @param id [Symbol] # def id(id) @identifier = id end # @param id [Symbol] # @param value [String] # def text(id, value) component_prototypes[id] = Argyle::Prototype.new(Argyle::Component::Text, {value: value, area: @current_area}) end # @param id [Symbol] # # @raise [Argyle::Error::RuntimeError] When area calls are nested # def area(id) raise Argyle::Error::RuntimeError.new('Areas cannot be nested') unless @current_area == :main @current_area = id yield @current_area = :main end # @param id [Symbol] # def layout(id) @layout_id = id end 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 end end |
#identifier ⇒ Symbol (readonly)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/argyle/page/base.rb', line 10 class Argyle::Page::Base attr_reader :components, :layout def initialize(components, layout) @components = components @layout = layout end # @!attribute [r] component_prototypes # @return [Hash{Symbol=>Argyle::Prototype}] # # @!attribute [r] layout_id # @return [Symbol] # # @!attribute [r] id # @return [Symbol] # class << self attr_reader :component_prototypes, :layout_id, :identifier private # @param id [Symbol] # def id(id) @identifier = id end # @param id [Symbol] # @param value [String] # def text(id, value) component_prototypes[id] = Argyle::Prototype.new(Argyle::Component::Text, {value: value, area: @current_area}) end # @param id [Symbol] # # @raise [Argyle::Error::RuntimeError] When area calls are nested # def area(id) raise Argyle::Error::RuntimeError.new('Areas cannot be nested') unless @current_area == :main @current_area = id yield @current_area = :main end # @param id [Symbol] # def layout(id) @layout_id = id end 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 end end |
#layout ⇒ Argyle::Layout::Base (readonly)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/argyle/page/base.rb', line 10 class Argyle::Page::Base attr_reader :components, :layout def initialize(components, layout) @components = components @layout = layout end # @!attribute [r] component_prototypes # @return [Hash{Symbol=>Argyle::Prototype}] # # @!attribute [r] layout_id # @return [Symbol] # # @!attribute [r] id # @return [Symbol] # class << self attr_reader :component_prototypes, :layout_id, :identifier private # @param id [Symbol] # def id(id) @identifier = id end # @param id [Symbol] # @param value [String] # def text(id, value) component_prototypes[id] = Argyle::Prototype.new(Argyle::Component::Text, {value: value, area: @current_area}) end # @param id [Symbol] # # @raise [Argyle::Error::RuntimeError] When area calls are nested # def area(id) raise Argyle::Error::RuntimeError.new('Areas cannot be nested') unless @current_area == :main @current_area = id yield @current_area = :main end # @param id [Symbol] # def layout(id) @layout_id = id end 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 end end |