Class: Sinclair::Options
- Inherits:
-
Object
- Object
- Sinclair::Options
- Extended by:
- ClassMethods
- Defined in:
- lib/sinclair/options.rb,
lib/sinclair/options/builder.rb,
lib/sinclair/options/class_methods.rb
Overview
Base options class
Defined Under Namespace
Modules: ClassMethods Classes: Builder
Instance Method Summary collapse
-
#==(other) ⇒ TrueClass, FalseClass
returns if other equals to self.
-
#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
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
30 31 32 33 34 35 36 |
# File 'lib/sinclair/options.rb', line 30 def initialize( = {}) () .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Method Details
#==(other) ⇒ TrueClass, FalseClass
returns if other equals to self
67 68 69 70 71 72 73 |
# File 'lib/sinclair/options.rb', line 67 def ==(other) return false unless self.class == other.class .all? do |name| public_send(name) == other.public_send(name) end end |
#to_h ⇒ Hash
Returns a hash with the current options
56 57 58 59 60 |
# File 'lib/sinclair/options.rb', line 56 def to_h .inject({}) do |hash, option| hash.merge(option => public_send(option)) end end |