Class: Strict::Attributes::Dsl
- Inherits:
- BasicObject
- Includes:
- Dsl::Coercible, Dsl::Validatable
- Defined in:
- lib/strict/attributes/dsl.rb
Instance Attribute Summary collapse
-
#__strict_dsl_internal_attributes ⇒ Object
readonly
Returns the value of attribute __strict_dsl_internal_attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Dsl
constructor
A new instance of Dsl.
- #method_missing(name, *args, **kwargs) ⇒ Object
- #respond_to_missing?(method_name, _include_private = nil) ⇒ Boolean
- #strict_attribute(*args, **kwargs) ⇒ Object
Methods included from Dsl::Validatable
#AllOf, #AnyOf, #Anything, #ArrayOf, #Boolean, #HashOf, #RangeOf
Methods included from Dsl::Coercible
Constructor Details
#initialize ⇒ Dsl
Returns a new instance of Dsl.
19 20 21 |
# File 'lib/strict/attributes/dsl.rb', line 19 def initialize @__strict_dsl_internal_attributes = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/strict/attributes/dsl.rb', line 29 def method_missing(name, *args, **kwargs) if respond_to_missing?(name) strict_attribute(name, *args, **kwargs) else super end end |
Instance Attribute Details
#__strict_dsl_internal_attributes ⇒ Object (readonly)
Returns the value of attribute __strict_dsl_internal_attributes.
17 18 19 |
# File 'lib/strict/attributes/dsl.rb', line 17 def __strict_dsl_internal_attributes @__strict_dsl_internal_attributes end |
Class Method Details
.run(&block) ⇒ Object
7 8 9 10 11 |
# File 'lib/strict/attributes/dsl.rb', line 7 def run(&block) dsl = new dsl.instance_eval(&block) ::Strict::Attributes::Configuration.new(attributes: dsl.__strict_dsl_internal_attributes.values) end |
Instance Method Details
#respond_to_missing?(method_name, _include_private = nil) ⇒ Boolean
37 38 39 40 |
# File 'lib/strict/attributes/dsl.rb', line 37 def respond_to_missing?(method_name, _include_private = nil) first_letter = method_name.to_s.each_char.first first_letter.eql?(first_letter.downcase) end |