Module: Sinclair::Options::ClassMethods
- Included in:
- Sinclair::Options
- Defined in:
- lib/sinclair/options/class_methods.rb
Overview
Class Methods for Sinclair::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
25 26 27 |
# File 'lib/sinclair/options/class_methods.rb', line 25 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
35 36 37 |
# File 'lib/sinclair/options/class_methods.rb', line 35 def ||= 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
12 13 14 |
# File 'lib/sinclair/options/class_methods.rb', line 12 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
88 89 90 |
# File 'lib/sinclair/options/class_methods.rb', line 88 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
44 45 46 |
# File 'lib/sinclair/options/class_methods.rb', line 44 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
64 65 66 |
# File 'lib/sinclair/options/class_methods.rb', line 64 def (*) Builder.new(self, *).build end |