Class: Curlybars::Node::Item

Inherits:
Struct
  • Object
show all
Defined in:
lib/curlybars/node/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#itemObject

Returns the value of attribute item

Returns:

  • (Object)

    the current value of item



3
4
5
# File 'lib/curlybars/node/item.rb', line 3

def item
  @item
end

Instance Method Details

#cache_keyObject



23
24
25
26
27
28
# File 'lib/curlybars/node/item.rb', line 23

def cache_key
  [
    item.cache_key,
    self.class.name
  ].join("/")
end

#compileObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/curlybars/node/item.rb', line 4

def compile
  # NOTE: the following is a heredoc string, representing the ruby code fragment
  # outputted by this node.
  <<-RUBY
    ::Module.new do
      def self.exec(contexts, rendering, variables, buffer)
        rendering.check_timeout!
        #{item.compile}
      end
    end.exec(contexts, rendering, variables, buffer)
  RUBY
end

#validate(branches) ⇒ Object



17
18
19
20
21
# File 'lib/curlybars/node/item.rb', line 17

def validate(branches)
  item.validate(branches)
rescue Curlybars::Error::Validate => path_error
  path_error
end