Class: Ant::Element
- Inherits:
-
Object
- Object
- Ant::Element
- Defined in:
- lib/rake/ant/element.rb
Overview
This is really the metadata of the element coupled with the logic for instantiating an instance of an element and evaluating it. My intention is to decouple these two pieces. This has extra value since we can then also make two types of instances for both top-level tasks and for targets since we have some conditionals which would then be eliminated
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(parent, args = {}, &code) ⇒ Object
-
#initialize(ant, name, clazz = nil) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(ant, name, clazz = nil) ⇒ Element
33 34 35 |
# File 'lib/rake/ant/element.rb', line 33 def initialize(ant, name, clazz = nil) @ant, @name, @clazz = ant, name, clazz end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/rake/ant/element.rb', line 31 def name @name end |
Instance Method Details
#call(parent, args = {}, &code) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rake/ant/element.rb', line 37 def call(parent, args={}, &code) element = create_element(parent) assign_attributes element, args define_nested_elements element if @clazz code.arity==1 ? code[element] : element.instance_eval(&code) if block_given? if parent.respond_to? :add_child # Task parent.add_child element parent.runtime_configurable_wrapper.add_child element.runtime_configurable_wrapper elsif parent.respond_to? :add_task # Target parent.add_task element else # Just run it now @ant.project.log "#{element.location.to_s}: Executing #{name}", 5 element.owning_target = Target.new.tap {|t| t.name = ""} element.maybe_configure element.execute end end |