Class: Slim::LogicLess::Context::Scope Private
- Inherits:
-
Object
- Object
- Slim::LogicLess::Context::Scope
- Defined in:
- lib/slim/logic_less/context.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #dict ⇒ Object writeonly private
- #lookup ⇒ Object readonly private
Instance Method Summary collapse
- #[](name) ⇒ Object private
-
#initialize(dict, lookup, parent = nil) ⇒ Scope
constructor
private
A new instance of Scope.
- #lambda(name, &block) ⇒ Object private
- #to_s ⇒ Object private
Constructor Details
#initialize(dict, lookup, parent = nil) ⇒ Scope
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Scope.
59 60 61 |
# File 'lib/slim/logic_less/context.rb', line 59 def initialize(dict, lookup, parent = nil) @dict, @lookup, @parent = dict, lookup, parent end |
Instance Attribute Details
#dict=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/slim/logic_less/context.rb', line 57 def dict=(value) @dict = value end |
#lookup ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/slim/logic_less/context.rb', line 56 def lookup @lookup end |
Instance Method Details
#[](name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/slim/logic_less/context.rb', line 80 def [](name) @lookup.each do |lookup| case lookup when :method return @dict.public_send(name) if @dict.respond_to?(name, false) when :symbol return @dict[name] if has_key?(name) when :string return @dict[name.to_s] if has_key?(name.to_s) when :instance_variable var_name = "@#{name}" return @dict.instance_variable_get(var_name) if instance_variable?(var_name) end end @parent[name] if @parent end |
#lambda(name, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/slim/logic_less/context.rb', line 63 def lambda(name, &block) @lookup.each do |lookup| case lookup when :method return @dict.public_send(name, &block) if @dict.respond_to?(name, false) when :symbol return @dict[name].call(&block) if has_key?(name) when :string return @dict[name.to_s].call(&block) if has_key?(name.to_s) when :instance_variable var_name = "@#{name}" return @dict.instance_variable_get(var_name).call(&block) if instance_variable?(var_name) end end @parent.lambda(name, &block) if @parent end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 |
# File 'lib/slim/logic_less/context.rb', line 97 def to_s @dict.to_s end |