Class: LcpRuby::Dsl::DslLoader::EvalContext
- Inherits:
-
Object
- Object
- LcpRuby::Dsl::DslLoader::EvalContext
- Defined in:
- lib/lcp_ruby/dsl/dsl_loader.rb
Overview
Isolated evaluation context to prevent DSL files from accessing the DslLoader internals.
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
Instance Method Summary collapse
- #define_model(name, inherits: nil, &block) ⇒ Object
-
#initialize ⇒ EvalContext
constructor
A new instance of EvalContext.
Constructor Details
#initialize ⇒ EvalContext
Returns a new instance of EvalContext.
257 258 259 |
# File 'lib/lcp_ruby/dsl/dsl_loader.rb', line 257 def initialize @definitions = [] end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
255 256 257 |
# File 'lib/lcp_ruby/dsl/dsl_loader.rb', line 255 def definitions @definitions end |
Instance Method Details
#define_model(name, inherits: nil, &block) ⇒ Object
261 262 263 264 265 266 267 |
# File 'lib/lcp_ruby/dsl/dsl_loader.rb', line 261 def define_model(name, inherits: nil, &block) builder = ModelBuilder.new(name) builder.instance_eval(&block) hash = builder.to_hash hash["inherits"] = inherits.to_s if inherits @definitions << Metadata::ModelDefinition.from_hash(hash) end |