Class: Roda::Component::Instance
- Defined in:
- lib/roda/component/instance.rb
Instance Attribute Summary collapse
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #client? ⇒ Boolean (also: #client)
-
#display(*args, &block) ⇒ Object
this is a hack because it seems like display is a ruby object method when doing method(:display) it gives #<Method: # Roda::Component::Instance(Kernel)#display>.
-
#initialize(instance, scope = false) ⇒ Instance
constructor
A new instance of Instance.
- #method_missing(method, *args, &block) ⇒ Object
- #server? ⇒ Boolean (also: #server)
Constructor Details
#initialize(instance, scope = false) ⇒ Instance
Returns a new instance of Instance.
6 7 8 9 |
# File 'lib/roda/component/instance.rb', line 6 def initialize instance, scope = false @instance = instance @scope = scope end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/roda/component/instance.rb', line 17 def method_missing method, *args, &block if instance.respond_to? method, true instance.send method, *args, &block elsif server && scope && scope.respond_to?(method, true) scope.send method, *args, &block else super end end |
Instance Attribute Details
#instance ⇒ Object
Returns the value of attribute instance.
4 5 6 |
# File 'lib/roda/component/instance.rb', line 4 def instance @instance end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/roda/component/instance.rb', line 4 def scope @scope end |
Instance Method Details
#client? ⇒ Boolean Also known as: client
32 33 34 |
# File 'lib/roda/component/instance.rb', line 32 def client? RUBY_ENGINE == 'opal' end |
#display(*args, &block) ⇒ Object
this is a hack because it seems like display is a ruby object method when doing method(:display) it gives #<Method: # Roda::Component::Instance(Kernel)#display>
13 14 15 |
# File 'lib/roda/component/instance.rb', line 13 def display *args, &block method_missing('display', *args, &block) end |
#server? ⇒ Boolean Also known as: server
27 28 29 |
# File 'lib/roda/component/instance.rb', line 27 def server? RUBY_ENGINE == 'ruby' end |