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.
60 61 62 |
# File 'lib/slim/logic_less/context.rb', line 60 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.
58 59 60 |
# File 'lib/slim/logic_less/context.rb', line 58 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.
57 58 59 |
# File 'lib/slim/logic_less/context.rb', line 57 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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/slim/logic_less/context.rb', line 81 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.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/slim/logic_less/context.rb', line 64 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.
98 99 100 |
# File 'lib/slim/logic_less/context.rb', line 98 def to_s @dict.to_s end |