Module: DSLKit::DynamicScope
- Includes:
- Scope
- Defined in:
- lib/dslkit/polite.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
699 700 701 702 703 704 705 706 707 708 709 |
# File 'lib/dslkit/polite.rb', line 699 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.
686 687 688 |
# File 'lib/dslkit/polite.rb', line 686 def dynamic_scope_name @dynamic_scope_name end |
Instance Method Details
#dynamic_defined?(id) ⇒ Boolean
688 689 690 691 692 |
# File 'lib/dslkit/polite.rb', line 688 def dynamic_defined?(id) self.dynamic_scope_name ||= :variables scope_reverse(dynamic_scope_name) { |c| c.key?(id) and return true } false end |