Class: Build::RuleNode
- Inherits:
-
Graph::Node
- Object
- Graph::Node
- Build::RuleNode
- Defined in:
- lib/build/rule_node.rb
Overview
Represents a build graph node that applies a specific rule with given arguments.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#apply!(scope) ⇒ Object
Apply the rule in the given scope, then invoke the callback if present.
- #hash ⇒ Object
-
#initialize(rule, arguments, &block) ⇒ RuleNode
constructor
Initialize the rule node.
- #inspect ⇒ Object
- #name ⇒ Object
- #task_class(parent_task) ⇒ Object
Constructor Details
#initialize(rule, arguments, &block) ⇒ RuleNode
Initialize the rule node.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/build/rule_node.rb', line 14 def initialize(rule, arguments, &block) @arguments = arguments @rule = rule @callback = block inputs, outputs = @rule.files(@arguments) super(inputs, outputs) end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
25 26 27 |
# File 'lib/build/rule_node.rb', line 25 def arguments @arguments end |
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
27 28 29 |
# File 'lib/build/rule_node.rb', line 27 def callback @callback end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
26 27 28 |
# File 'lib/build/rule_node.rb', line 26 def rule @rule end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/build/rule_node.rb', line 30 def == other super and @arguments == other.arguments and @rule == other.rule and @callback == other.callback end |
#apply!(scope) ⇒ Object
Apply the rule in the given scope, then invoke the callback if present.
54 55 56 57 58 59 60 |
# File 'lib/build/rule_node.rb', line 54 def apply!(scope) @rule.apply!(scope, @arguments) if @callback scope.instance_exec(@arguments, &@callback) end end |
#hash ⇒ Object
38 39 40 |
# File 'lib/build/rule_node.rb', line 38 def hash super ^ @arguments.hash ^ @rule.hash ^ @callback.hash end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/build/rule_node.rb', line 63 def inspect @rule.name.inspect end |
#name ⇒ Object
48 49 50 |
# File 'lib/build/rule_node.rb', line 48 def name @rule.name end |
#task_class(parent_task) ⇒ Object
43 44 45 |
# File 'lib/build/rule_node.rb', line 43 def task_class(parent_task) parent_task.class end |