Class: Resourcerer::ResourceConfiguration
- Inherits:
-
Object
- Object
- Resourcerer::ResourceConfiguration
- Defined in:
- lib/resourcerer/resource_configuration.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #assign(&block) ⇒ Object
- #build(&block) ⇒ Object
- #define_option_method(name) ⇒ Object
-
#find(&block) ⇒ Object
DSL.
-
#initialize(options = {}) ⇒ ResourceConfiguration
constructor
A new instance of ResourceConfiguration.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ResourceConfiguration
Returns a new instance of ResourceConfiguration.
7 8 9 |
# File 'lib/resourcerer/resource_configuration.rb', line 7 def initialize(={}) @options = || {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
11 12 13 14 15 |
# File 'lib/resourcerer/resource_configuration.rb', line 11 def method_missing(name, *args) super if args.size > 1 define_option_method(name) send(name, args.first) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/resourcerer/resource_configuration.rb', line 5 def @options end |
Instance Method Details
#assign(&block) ⇒ Object
37 38 39 |
# File 'lib/resourcerer/resource_configuration.rb', line 37 def assign(&block) [:attributes] = block end |
#build(&block) ⇒ Object
33 34 35 |
# File 'lib/resourcerer/resource_configuration.rb', line 33 def build(&block) [:builder] = block end |
#define_option_method(name) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/resourcerer/resource_configuration.rb', line 17 def define_option_method(name) # We chose not caching the value inside the method because it's more flexible self.class.class_eval <<-EVAL def #{name}(value=nil) options[:#{name}] = value if value options[:#{name}] end EVAL end |
#find(&block) ⇒ Object
DSL
29 30 31 |
# File 'lib/resourcerer/resource_configuration.rb', line 29 def find(&block) [:finder] = block end |