Class: Slim::LogicLess::Context Private
- Inherits:
-
Object
- Object
- Slim::LogicLess::Context
- 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.
Defined Under Namespace
Classes: Scope
Instance Method Summary collapse
- #[](name) ⇒ Object private
-
#initialize(dict, lookup) ⇒ Context
constructor
private
A new instance of Context.
- #inverted_section(name) ⇒ Object private
- #lambda(name) ⇒ Object private
- #section(name) ⇒ Object private
- #to_s ⇒ Object private
Constructor Details
#initialize(dict, lookup) ⇒ Context
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 Context.
5 6 7 |
# File 'lib/slim/logic_less/context.rb', line 5 def initialize(dict, lookup) @scope = [Scope.new(dict, 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.
9 10 11 |
# File 'lib/slim/logic_less/context.rb', line 9 def [](name) scope[name] end |
#inverted_section(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.
43 44 45 46 |
# File 'lib/slim/logic_less/context.rb', line 43 def inverted_section(name) value = scope[name] yield if !value || (value.respond_to?(:empty?) && value.empty?) end |
#lambda(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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/slim/logic_less/context.rb', line 13 def lambda(name) scope.lambda(name) do |*dict| if dict.empty? yield else new_scope do dict.inject('') do |result, d| scope.dict = d result << yield end end end end end |
#section(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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/slim/logic_less/context.rb', line 28 def section(name) if dict = scope[name] if !dict.respond_to?(:has_key?) && dict.respond_to?(:each) new_scope do dict.each do |d| scope.dict = d yield end end else new_scope(dict) { yield } end end 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.
48 49 50 |
# File 'lib/slim/logic_less/context.rb', line 48 def to_s scope.to_s end |