Class: Kamaze::Project::Config Abstract
Overview
This class is abstract.
Subclass and override #defaults to implement
Generic config(urator) class
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#configure(configurable) ⇒ Object
Configure an object (manipulating its properties).
- #defaults ⇒ Hash
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
- #to_h ⇒ Hash
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/kamaze/project/config.rb', line 40 def method_missing(method, *args, &block) if respond_to_missing?(method) @attributes.public_send(method, *args, &block) else super end end |
Instance Attribute Details
#attributes ⇒ Kamaze::Project::Struct (readonly)
17 18 19 |
# File 'lib/kamaze/project/config.rb', line 17 def attributes @attributes end |
Instance Method Details
#configure(configurable) ⇒ Object
Configure an object (manipulating its properties)
27 28 29 30 31 32 33 |
# File 'lib/kamaze/project/config.rb', line 27 def configure(configurable) to_h.each do |k, v| configurable.__send__("#{k}=", v) end configurable end |
#defaults ⇒ Hash
55 56 57 |
# File 'lib/kamaze/project/config.rb', line 55 def defaults {} end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
48 49 50 51 52 |
# File 'lib/kamaze/project/config.rb', line 48 def respond_to_missing?(method, include_private = false) return true if attributes.respond_to?(method, include_private) super(method, include_private) end |
#to_h ⇒ Hash
36 37 38 |
# File 'lib/kamaze/project/config.rb', line 36 def to_h attributes.to_h end |