Class: Attributor::HashDSLCompiler
- Inherits:
-
DSLCompiler
- Object
- DSLCompiler
- Attributor::HashDSLCompiler
- Defined in:
- lib/attributor/hash_dsl_compiler.rb
Defined Under Namespace
Classes: Requirement, RequiresDSL
Constant Summary
Constants included from Attributor
DEFAULT_ROOT_CONTEXT, MODULE_PREFIX, MODULE_PREFIX_REGEX, ROOT_PREFIX, SEPARATOR, VERSION
Instance Attribute Summary
Attributes inherited from DSLCompiler
Instance Method Summary collapse
Methods inherited from DSLCompiler
#add_reference_to_block, #attribute, #attributes, #define, #extra, #initialize, #key, #parse, #resolve_type_for_block, #resolve_type_for_no_block
Methods included from Attributor
#_get_attr, errorize_value, find_type, humanize_context, recursive_to_h, resolve_type, type_name
Constructor Details
This class inherits a constructor from Attributor::DSLCompiler
Instance Method Details
#_requirements_dsl ⇒ Object
123 124 125 |
# File 'lib/attributor/hash_dsl_compiler.rb', line 123 def _requirements_dsl @requirements_dsl ||= RequiresDSL.new(@target) end |
#requires(*spec, **opts, &block) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/attributor/hash_dsl_compiler.rb', line 127 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 |