Module: Sinclair::Options::ClassMethods
- Included in:
- Sinclair::Options
- Defined in:
- lib/sinclair/options/class_methods.rb
Overview
Class Methods for Sinclai::Options
Instance Method Summary collapse
-
#allow(name) ⇒ Set<Symbol>
private
Allow new option.
-
#allowed_options ⇒ Set<Symbol>
private
Options allowed when initializing options.
-
#invalid_options_in(names) ⇒ Array<Symbol>
private
returns invalid options.
-
#skip_validation ⇒ TrueClass
Changes class to skip attributes validation.
-
#skip_validation? ⇒ TrueClass, FalseClass
private
checks if class skips initialization validation.
-
#with_options(*options) ⇒ Array<MethodDefinition>
Add available options.
Instance Method Details
#allow(name) ⇒ Set<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allow new option
This does not create the method
27 28 29 |
# File 'lib/sinclair/options/class_methods.rb', line 27 def allow(name) << name.to_sym end |
#allowed_options ⇒ Set<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Options allowed when initializing options
37 38 39 |
# File 'lib/sinclair/options/class_methods.rb', line 37 def @allowed_options ||= superclass.try(:allowed_options).dup || Set.new end |
#invalid_options_in(names) ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
returns invalid options
14 15 16 |
# File 'lib/sinclair/options/class_methods.rb', line 14 def (names) names.map(&:to_sym) - .to_a end |
#skip_validation ⇒ TrueClass
Changes class to skip attributes validation
when initializing options, options will accept any arguments when validation is skipped
94 95 96 |
# File 'lib/sinclair/options/class_methods.rb', line 94 def skip_validation @skip_validation = true end |
#skip_validation? ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
checks if class skips initialization validation
46 47 48 |
# File 'lib/sinclair/options/class_methods.rb', line 46 def skip_validation? @skip_validation ||= superclass.try(:skip_validation?) || false end |
#with_options(*options) ⇒ Array<MethodDefinition> #with_options(*options, **defaults) ⇒ Array<MethodDefinition>
Add available options
69 70 71 |
# File 'lib/sinclair/options/class_methods.rb', line 69 def (*) Builder.new(self, *).build end |