# File lib/rgen/instantiator/abstract_instantiator.rb, line 13 def initialize(env) @env = env end
Specifies that attribute should be resolved. If :class is specified, resolve attribute only for objects of type class. The block must return the value to which the attribute should be assigned. The object for which the attribute is to be resolved will be accessible in the current context within the block.
# File lib/rgen/instantiator/abstract_instantiator.rb, line 23 def self.resolve(attribute, desc=nil, &block) from = (desc.is_a?(Hash) && desc[:class]) self.resolver_descs ||= [] self.resolver_descs << ResolverDescription.new(from, attribute, block) end
Resolves attribute to a model element which has attribute :id set to the value currently in attribute :src
# File lib/rgen/instantiator/abstract_instantiator.rb, line 32 def self.resolve_by_id(attribute, desc) id_attr = (desc.is_a?(Hash) && desc[:id]) src_attr = (desc.is_a?(Hash) && desc[:src]) raise StandardError.new("No id attribute given.") unless id_attr resolve(attribute) do @env.find(id_attr => @current_object.send(src_attr)).first end end
Generated with the Darkfish Rdoc Generator 2.