Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Avoid duplicate method calls by using an lvar
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu committed Mar 4, 2013
1 parent 3c897ba commit cd88ba4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/data_mapper/finalizer/base_relation_mappers_finalizer.rb
Expand Up @@ -50,9 +50,11 @@ def finalize_edges
private

def registered_node(mapper, name, header)
graph = relations
relation = registered_relation(name, mapper)
node = relations.build_node(name, relation, header)
relations.add_node(node)

node = graph.build_node(name, relation, header)
graph.add_node(node)
node
end

Expand Down
7 changes: 4 additions & 3 deletions lib/data_mapper/mapper.rb
Expand Up @@ -73,12 +73,13 @@ def self.map(name, *args)
options = Utils.extract_options(args)
options = options.merge(:type => type) if type

attribute = attributes[name]
attribute_set = attributes
attribute = attribute_set[name]

if attribute
attributes << attribute.clone(options)
attribute_set << attribute.clone(options)
else
attributes.add(name, options)
attribute_set.add(name, options)
end

self
Expand Down

0 comments on commit cd88ba4

Please sign in to comment.