Class: Yutani::Provider
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#provider_name ⇒ Object
Returns the value of attribute provider_name.
Attributes inherited from DSLEntity
Instance Method Summary collapse
- #[]=(k, v) ⇒ Object
-
#initialize(provider_name, **scope, &block) ⇒ Provider
constructor
A new instance of Provider.
- #method_missing(name, *args, &block) ⇒ Object
- #to_h ⇒ Object
Methods inherited from DSLEntity
Constructor Details
#initialize(provider_name, **scope, &block) ⇒ Provider
Returns a new instance of Provider.
7 8 9 10 11 12 13 |
# File 'lib/yutani/provider.rb', line 7 def initialize(provider_name, **scope, &block) @provider_name = provider_name @scope = HashWithIndifferentAccess.new(scope) @fields = {} instance_eval &block if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/yutani/provider.rb', line 25 def method_missing(name, *args, &block) if block_given? raise StandardError, "provider properties do not accept blocks as parameters" else @fields[name] = args.first end end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
5 6 7 |
# File 'lib/yutani/provider.rb', line 5 def fields @fields end |
#provider_name ⇒ Object
Returns the value of attribute provider_name.
5 6 7 |
# File 'lib/yutani/provider.rb', line 5 def provider_name @provider_name end |
Instance Method Details
#[]=(k, v) ⇒ Object
15 16 17 |
# File 'lib/yutani/provider.rb', line 15 def []=(k,v) @fields[k] = v end |
#to_h ⇒ Object
19 20 21 22 23 |
# File 'lib/yutani/provider.rb', line 19 def to_h { @provider_name => @fields } end |