Class: CML::LogicTree::Node
- Inherits:
-
Object
- Object
- CML::LogicTree::Node
- Defined in:
- lib/cml/logic.rb
Overview
A node in CML::LogicTree, containing a CML::Tag in @tag
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#dependencies_on(&block) ⇒ Object
Hash of tag dependency details (name/is_not/match_key) on (only-if logic).
-
#depends_on ⇒ Object
Array of Node instances the tag depends on (only-if logic).
- #depth ⇒ Object
- #has_grouped_logic? ⇒ Boolean
- #has_liquid_logic? ⇒ Boolean
- #has_logic? ⇒ Boolean
-
#initialize(tree, tag) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(tree, tag) ⇒ Node
Returns a new instance of Node.
83 84 85 86 87 88 |
# File 'lib/cml/logic.rb', line 83 def initialize( tree, tag ) @tree = tree @tag = tag @tag.logic_tree = @tree self end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
81 82 83 |
# File 'lib/cml/logic.rb', line 81 def tag @tag end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
81 82 83 |
# File 'lib/cml/logic.rb', line 81 def tree @tree end |
Instance Method Details
#dependencies_on(&block) ⇒ Object
Hash of tag dependency details (name/is_not/match_key) on (only-if logic)
95 96 97 98 99 100 101 |
# File 'lib/cml/logic.rb', line 95 def dependencies_on(&block) if block_given? @tag.dependencies_on_fields(&block) else @dependencies_on_nodes ||= @tag.dependencies_on_fields end end |
#depends_on ⇒ Object
Array of Node instances the tag depends on (only-if logic)
104 105 106 107 108 |
# File 'lib/cml/logic.rb', line 104 def depends_on @depends_on_nodes ||= @tag.depends_on_fields.map do |field_name| @tree.nodes[field_name] end.compact.uniq end |
#depth ⇒ Object
90 91 92 |
# File 'lib/cml/logic.rb', line 90 def depth @depth ||= @tree.depth( self ) end |
#has_grouped_logic? ⇒ Boolean
114 115 116 117 |
# File 'lib/cml/logic.rb', line 114 def has_grouped_logic? @tag.depends_on_fields !!@tag.has_grouped_logic end |
#has_liquid_logic? ⇒ Boolean
119 120 121 122 |
# File 'lib/cml/logic.rb', line 119 def has_liquid_logic? @tag.depends_on_fields !!@tag.has_liquid_logic end |
#has_logic? ⇒ Boolean
110 111 112 |
# File 'lib/cml/logic.rb', line 110 def has_logic? self.depends_on.size > 0 end |