Class: Peony::Settings
- Inherits:
-
Object
- Object
- Peony::Settings
- Defined in:
- lib/peony/settings.rb
Instance Attribute Summary collapse
-
#current_scope ⇒ Object
readonly
Returns the value of attribute current_scope.
-
#root_scope ⇒ Object
readonly
Returns the value of attribute root_scope.
Instance Method Summary collapse
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, include_all = true) ⇒ Boolean
- #with_scope(name) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/peony/settings.rb', line 19 def method_missing(method, *args, &block) if current_scope.respond_to?(method, false) current_scope.__send__(method, *args, &block) else super end end |
Instance Attribute Details
#current_scope ⇒ Object (readonly)
Returns the value of attribute current_scope.
3 4 5 |
# File 'lib/peony/settings.rb', line 3 def current_scope @current_scope end |
#root_scope ⇒ Object (readonly)
Returns the value of attribute root_scope.
3 4 5 |
# File 'lib/peony/settings.rb', line 3 def root_scope @root_scope end |
Instance Method Details
#respond_to_missing?(method, include_all = true) ⇒ Boolean
27 28 29 |
# File 'lib/peony/settings.rb', line 27 def respond_to_missing?(method, include_all = true) current_scope.respond_to?(method, include_all) end |
#with_scope(name) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/peony/settings.rb', line 9 def with_scope(name) original_scope = current_scope begin @current_scope = original_scope.new_scope(name) yield ensure @current_scope = original_scope end end |