Skip to content

Commit

Permalink
Some code cleaning which was in #476
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic committed Sep 21, 2014
1 parent 3451ece commit 0559cd2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/neo4j/shared/property.rb
Expand Up @@ -39,16 +39,15 @@ def read_attribute(name)

def default_properties=(properties)
keys = self.class.default_properties.keys
@default_properties = properties.reject{|key| !keys.include?(key)}
@default_properties = properties.select {|key| keys.include?(key) }
end

def default_property(key)
keys = self.class.default_properties.keys
keys.include?(key.to_sym) ? default_properties[key.to_sym] : nil
default_properties[key.to_sym]
end

def default_properties
@default_properties ||= {}
@default_properties ||= Hash.new(nil)
# keys = self.class.default_properties.keys
# _persisted_obj.props.reject{|key| !keys.include?(key)}
end
Expand Down Expand Up @@ -173,8 +172,8 @@ def default_properties
end

def default_property_values(instance)
default_properties.inject({}) do |result,pair|
result.tap{|obj| obj[pair[0]] = pair[1].call(instance)}
default_properties.each_with_object({}) do |(key, block),result|
result[key] = block.call(instance)
end
end

Expand Down

0 comments on commit 0559cd2

Please sign in to comment.