Class: Attributor::HashDSLCompiler
- Inherits:
-
DSLCompiler
- Object
- DSLCompiler
- Attributor::HashDSLCompiler
- Defined in:
- lib/attributor/hash_dsl_compiler.rb
Defined Under Namespace
Classes: Requirement, RequiresDSL
Instance Attribute Summary
Attributes inherited from DSLCompiler
Instance Method Summary collapse
Methods inherited from DSLCompiler
#attribute, #attributes, #define, #extra, #initialize, #key, #parse
Constructor Details
This class inherits a constructor from Attributor::DSLCompiler
Instance Method Details
#_requirements_dsl ⇒ Object
122 123 124 |
# File 'lib/attributor/hash_dsl_compiler.rb', line 122 def _requirements_dsl @requirements_dsl ||= RequiresDSL.new(@target) end |
#requires(*spec, **opts, &block) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/attributor/hash_dsl_compiler.rb', line 126 def requires(*spec, **opts, &block) if spec.empty? _requirements_dsl..merge(opts) unless opts.empty? if block_given? _requirements_dsl.instance_eval(&block) else _requirements_dsl end else _requirements_dsl.all(*spec, opts) end end |