Class: ActionView::Digestor::Node

Inherits:
Object
  • Object
show all
Defined in:
actionview/lib/action_view/digestor.rb

Direct Known Subclasses

Injected, Missing, Partial

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, logical_name, template, children = []) ⇒ Node

Returns a new instance of Node.


81
82
83
84
85
86
# File 'actionview/lib/action_view/digestor.rb', line 81

def initialize(name, logical_name, template, children = [])
  @name         = name
  @logical_name = logical_name
  @template     = template
  @children     = children
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children


74
75
76
# File 'actionview/lib/action_view/digestor.rb', line 74

def children
  @children
end

#logical_nameObject (readonly)

Returns the value of attribute logical_name


74
75
76
# File 'actionview/lib/action_view/digestor.rb', line 74

def logical_name
  @logical_name
end

#nameObject (readonly)

Returns the value of attribute name


74
75
76
# File 'actionview/lib/action_view/digestor.rb', line 74

def name
  @name
end

#templateObject (readonly)

Returns the value of attribute template


74
75
76
# File 'actionview/lib/action_view/digestor.rb', line 74

def template
  @template
end

Class Method Details

.create(name, logical_name, template, partial) ⇒ Object


76
77
78
79
# File 'actionview/lib/action_view/digestor.rb', line 76

def self.create(name, logical_name, template, partial)
  klass = partial ? Partial : Node
  klass.new(name, logical_name, template, [])
end

Instance Method Details

#dependency_digest(finder, stack) ⇒ Object


92
93
94
95
96
97
98
99
100
101
102
103
# File 'actionview/lib/action_view/digestor.rb', line 92

def dependency_digest(finder, stack)
  children.map do |node|
    if stack.include?(node)
      false
    else
      finder.digest_cache[node.name] ||= begin
                                           stack.push node
                                           node.digest(finder, stack).tap { stack.pop }
                                         end
    end
  end.join("-")
end

#digest(finder, stack = []) ⇒ Object


88
89
90
# File 'actionview/lib/action_view/digestor.rb', line 88

def digest(finder, stack = [])
  Digest::MD5.hexdigest("#{template.source}-#{dependency_digest(finder, stack)}")
end

#to_dep_mapObject


105
106
107
# File 'actionview/lib/action_view/digestor.rb', line 105

def to_dep_map
  children.any? ? { name => children.map(&:to_dep_map) } : name
end