Module: Virtus::Options
Overview
A module that adds class and instance level options
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.
Instance Method Details
#accept_options(*new_options) ⇒ self
Defines which options are valid for a given attribute class
47 48 49 50 51 52 |
# File 'lib/virtus/support/options.rb', line 47 def (*) () .each { |option| define_option_method(option) } descendants.each { |descendant| descendant.() } self end |
#accepted_options ⇒ Array
Returns an array of valid options
33 34 35 |
# File 'lib/virtus/support/options.rb', line 33 def @accepted_options ||= [] end |
#options ⇒ Hash
Returns default options hash for a given attribute class
16 17 18 19 20 21 |
# File 'lib/virtus/support/options.rb', line 16 def .each_with_object({}) do |option_name, | option_value = send(option_name) [option_name] = option_value unless option_value.nil? end end |