Class: Surrogate::Options
- Inherits:
-
Object
- Object
- Surrogate::Options
- Defined in:
- lib/surrogate/options.rb
Instance Attribute Summary collapse
-
#default_proc ⇒ Object
Returns the value of attribute default_proc.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #default(instance, args, &no_default) ⇒ Object
- #has?(name) ⇒ Boolean
-
#initialize(options, default_proc) ⇒ Options
constructor
A new instance of Options.
- #to_hash ⇒ Object
Constructor Details
#initialize(options, default_proc) ⇒ Options
Returns a new instance of Options.
5 6 7 |
# File 'lib/surrogate/options.rb', line 5 def initialize(, default_proc) self., self.default_proc = , default_proc end |
Instance Attribute Details
#default_proc ⇒ Object
Returns the value of attribute default_proc.
3 4 5 |
# File 'lib/surrogate/options.rb', line 3 def default_proc @default_proc end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/surrogate/options.rb', line 3 def @options end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/surrogate/options.rb', line 13 def [](key) [key] end |
#default(instance, args, &no_default) ⇒ Object
21 22 23 24 25 |
# File 'lib/surrogate/options.rb', line 21 def default(instance, args, &no_default) return [:default] if .has_key? :default return instance.instance_exec(*args, &default_proc) if default_proc no_default.call end |
#has?(name) ⇒ Boolean
9 10 11 |
# File 'lib/surrogate/options.rb', line 9 def has?(name) .has_key? name end |
#to_hash ⇒ Object
17 18 19 |
# File 'lib/surrogate/options.rb', line 17 def to_hash end |