Class: Strict::Methods::Dsl
- Inherits:
- BasicObject
- Includes:
- Dsl::Coercible, Dsl::Validatable
- Defined in:
- lib/strict/methods/dsl.rb
Instance Attribute Summary collapse
-
#__strict_dsl_internal_parameters ⇒ Object
readonly
Returns the value of attribute __strict_dsl_internal_parameters.
-
#__strict_dsl_internal_returns ⇒ Object
readonly
Returns the value of attribute __strict_dsl_internal_returns.
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
- #returns(*args, **kwargs) ⇒ Object
- #strict_parameter(*args, **kwargs) ⇒ Object
Methods included from Dsl::Validatable
#AllOf, #AnyOf, #Anything, #ArrayOf, #Boolean, #HashOf, #RangeOf
Methods included from Dsl::Coercible
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/strict/methods/dsl.rb', line 38 def method_missing(name, *args, **kwargs) if respond_to_missing?(name) strict_parameter(name, *args, **kwargs) else super end end |
Instance Attribute Details
#__strict_dsl_internal_parameters ⇒ Object (readonly)
Returns the value of attribute __strict_dsl_internal_parameters.
20 21 22 |
# File 'lib/strict/methods/dsl.rb', line 20 def __strict_dsl_internal_parameters @__strict_dsl_internal_parameters end |
#__strict_dsl_internal_returns ⇒ Object
Returns the value of attribute __strict_dsl_internal_returns.
20 21 22 |
# File 'lib/strict/methods/dsl.rb', line 20 def __strict_dsl_internal_returns @__strict_dsl_internal_returns end |
Class Method Details
.run(&block) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/strict/methods/dsl.rb', line 7 def run(&block) dsl = new dsl.instance_eval(&block) ::Strict::Methods::Configuration.new( parameters: dsl.__strict_dsl_internal_parameters.values, returns: dsl.__strict_dsl_internal_returns ) end |
Instance Method Details
#respond_to_missing?(method_name, _include_private = nil) ⇒ Boolean
46 47 48 49 |
# File 'lib/strict/methods/dsl.rb', line 46 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 |