Module: Tins::DynamicScope
- Includes:
- Scope
- Defined in:
- lib/tins/dslkit.rb
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#dynamic_scope_name ⇒ Object
Returns the value of attribute dynamic_scope_name.
Instance Method Summary collapse
Methods included from Scope
#scope, #scope_block, #scope_get, #scope_pop, #scope_push, #scope_reverse, #scope_top
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args) ⇒ Object
651 652 653 654 655 656 657 658 659 660 661 |
# File 'lib/tins/dslkit.rb', line 651 def method_missing(id, *args) self.dynamic_scope_name ||= :variables if args.empty? and scope_reverse(dynamic_scope_name) { |c| c.key?(id) and return c[id] } super elsif args.size == 1 and id.to_s =~ /(.*?)=\Z/ c = scope_top(dynamic_scope_name) or super c[$1] = args.first else super end end |
Instance Attribute Details
#dynamic_scope_name ⇒ Object
Returns the value of attribute dynamic_scope_name.
638 639 640 |
# File 'lib/tins/dslkit.rb', line 638 def dynamic_scope_name @dynamic_scope_name end |
Instance Method Details
#dynamic_defined?(id) ⇒ Boolean
640 641 642 643 644 |
# File 'lib/tins/dslkit.rb', line 640 def dynamic_defined?(id) self.dynamic_scope_name ||= :variables scope_reverse(dynamic_scope_name) { |c| c.key?(id) and return true } false end |