Class: Compositor::DSL
- Inherits:
-
Object
- Object
- Compositor::DSL
- Defined in:
- lib/compositor/dsl.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#generator ⇒ Object
Returns the value of attribute generator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context) ⇒ DSL
constructor
A new instance of DSL.
- #to_hash ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(context) ⇒ DSL
Returns a new instance of DSL.
6 7 8 |
# File 'lib/compositor/dsl.rb', line 6 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/compositor/dsl.rb', line 3 def context @context end |
#generator ⇒ Object
Returns the value of attribute generator.
4 5 6 |
# File 'lib/compositor/dsl.rb', line 4 def generator @generator end |
Class Method Details
.create(context, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/compositor/dsl.rb', line 10 def self.create(context, &block) dsl = new(context) context.instance_variables.each do |variable| dsl.instance_variable_set(variable, context.instance_variable_get(variable)) end dsl.instance_eval &block if block dsl end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/compositor/dsl.rb', line 23 def to_hash if generator generator.to_hash else nil end end |
#to_json(options = {}) ⇒ Object
19 20 21 |
# File 'lib/compositor/dsl.rb', line 19 def to_json( = {}) generator.to_json() end |