Class: Vigia::Adapter::Structure
- Inherits:
-
Object
- Object
- Vigia::Adapter::Structure
- Defined in:
- lib/vigia/adapter.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#contexts ⇒ Object
readonly
Returns the value of attribute contexts.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Class Method Summary collapse
Instance Method Summary collapse
- #after_initialize(&block) ⇒ Object
- #context(name, options = {}) ⇒ Object
- #group(name, options = {}) ⇒ Object
-
#initialize(adapter, template) ⇒ Structure
constructor
A new instance of Structure.
- #preload ⇒ Object
Constructor Details
#initialize(adapter, template) ⇒ Structure
Returns a new instance of Structure.
36 37 38 39 40 41 |
# File 'lib/vigia/adapter.rb', line 36 def initialize(adapter, template) @adapter = adapter @template = template @groups = {} @contexts = {} end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
34 35 36 |
# File 'lib/vigia/adapter.rb', line 34 def adapter @adapter end |
#contexts ⇒ Object (readonly)
Returns the value of attribute contexts.
34 35 36 |
# File 'lib/vigia/adapter.rb', line 34 def contexts @contexts end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
34 35 36 |
# File 'lib/vigia/adapter.rb', line 34 def groups @groups end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
34 35 36 |
# File 'lib/vigia/adapter.rb', line 34 def template @template end |
Class Method Details
.generate(adapter, structure) ⇒ Object
27 28 29 30 31 |
# File 'lib/vigia/adapter.rb', line 27 def generate(adapter, structure) instance = new(adapter, structure) instance.preload instance end |
Instance Method Details
#after_initialize(&block) ⇒ Object
50 51 52 |
# File 'lib/vigia/adapter.rb', line 50 def after_initialize(&block) adapter.instance_exec(&block) end |
#context(name, options = {}) ⇒ Object
58 59 60 |
# File 'lib/vigia/adapter.rb', line 58 def context(name, = {}) @contexts.merge!(name => ) end |
#group(name, options = {}) ⇒ Object
54 55 56 |
# File 'lib/vigia/adapter.rb', line 54 def group(name, = {}) @groups.merge!(name => ) end |
#preload ⇒ Object
43 44 45 46 47 48 |
# File 'lib/vigia/adapter.rb', line 43 def preload instance_exec(&template) groups.each { |name, | Vigia::Sail::Group.register(name, ) } contexts.each { |name, | Vigia::Sail::Context.register(name, ) } end |