Class: Sinclair::Options
- Extended by:
- ClassMethods
- Includes:
- Comparable
- Defined in:
- lib/sinclair/options.rb,
lib/sinclair/options/builder.rb,
lib/sinclair/options/class_methods.rb
Overview
Base options class
Direct Known Subclasses
Defined Under Namespace
Modules: ClassMethods Classes: Builder
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
-
#to_h ⇒ Hash
Returns a hash with the current options.
Methods included from ClassMethods
allow, allowed_options, invalid_options_in, skip_validation, skip_validation?, with_options
Methods included from Comparable
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
31 32 33 34 35 36 37 |
# File 'lib/sinclair/options.rb', line 31 def initialize( = {}) () .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash with the current options
57 58 59 60 61 |
# File 'lib/sinclair/options.rb', line 57 def to_h .inject({}) do |hash, option| hash.merge(option => public_send(option)) end end |