Class: Attributor::HashDSLCompiler

Inherits:
DSLCompiler show all
Defined in:
lib/attributor/hash_dsl_compiler.rb

Defined Under Namespace

Classes: Requirement, RequiresDSL

Instance Attribute Summary

Attributes inherited from DSLCompiler

#options, #target

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_dslObject



121
122
123
# File 'lib/attributor/hash_dsl_compiler.rb', line 121

def _requirements_dsl
  @requirements_dsl ||= RequiresDSL.new(@target)
end

#requires(*spec, **opts, &block) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/attributor/hash_dsl_compiler.rb', line 125

def requires(*spec,**opts,&block)
  if spec.empty?
    unless opts.empty?
      self._requirements_dsl.options.merge(opts)
    end
    if block_given?
      self._requirements_dsl.instance_eval(&block)
    else
      self._requirements_dsl
    end
  else
    self._requirements_dsl.all(*spec,opts)
  end
end