Module: Coercible::Options
- Included in:
- Coercer::Object
- Defined in:
- lib/support/options.rb
Overview
A module that adds class and instance level options
Constant Summary collapse
- Undefined =
Class.new.freeze
Class Method Summary collapse
-
.extended(descendant) ⇒ undefined
private
Hook called when descendant was extended.
Instance Method Summary collapse
-
#accept_options(*new_options) ⇒ self
Defines which options are valid for a given attribute class.
-
#accepted_options ⇒ Array
Returns an array of valid options.
-
#options ⇒ Hash
Returns default options hash for a given attribute class.
Class Method Details
.extended(descendant) ⇒ undefined
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.
Hook called when descendant was extended
14 15 16 |
# File 'lib/support/options.rb', line 14 def self.extended(descendant) descendant.extend(DescendantsTracker) end |
Instance Method Details
#accept_options(*new_options) ⇒ self
Defines which options are valid for a given attribute class
59 60 61 62 63 64 |
# File 'lib/support/options.rb', line 59 def (*) () .each { |option| define_option_method(option) } descendants.each { |descendant| descendant.() } self end |
#accepted_options ⇒ Array
Returns an array of valid options
45 46 47 |
# File 'lib/support/options.rb', line 45 def @accepted_options ||= [] end |
#options ⇒ Hash
Returns default options hash for a given attribute class
28 29 30 31 32 33 |
# File 'lib/support/options.rb', line 28 def .each_with_object({}) do |option_name, | option_value = send(option_name) [option_name] = option_value unless option_value.nil? end end |