Class: Bobkit::Scope
- Inherits:
-
Object
- Object
- Bobkit::Scope
- Includes:
- I18nMixin, SlimBridge
- Defined in:
- lib/bobkit/scope.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(scope = nil) ⇒ Scope
constructor
A new instance of Scope.
- #method_missing(method_name, *arguments) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Methods included from I18nMixin
Methods included from SlimBridge
Constructor Details
#initialize(scope = nil) ⇒ Scope
Returns a new instance of Scope.
8 9 10 |
# File 'lib/bobkit/scope.rb', line 8 def initialize(scope = nil) @scope = scope || {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/bobkit/scope.rb', line 12 def method_missing(method_name, *arguments, &) if scope.respond_to?(:key?) && scope.has_key?(method_name) scope[method_name] elsif scope.respond_to? method_name scope.send method_name, *arguments else super end end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/bobkit/scope.rb', line 6 def scope @scope end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'lib/bobkit/scope.rb', line 22 def respond_to_missing?(method_name, include_private = false) if (scope.respond_to?(:key?) && scope.has_key?(method_name)) || scope.respond_to?(method_name) true else super end end |