lib/nstore.rb in nstore-0.1.0 vs lib/nstore.rb in nstore-0.2.0

- old
+ new

@@ -27,13 +27,13 @@ end # List of Class methods going to be included above module ClassMethods def nstore(attribute, options) - prefix = options.fetch(:prefix, false) - stringify = options.fetch(:stringify, false) - accessors = options[:accessors] + prefix = options.fetch(:prefix, false) + stringify = options.fetch(:stringify, false) + accessors = options[:accessors] flat_accessors = [] deep_flatten(accessors, [], flat_accessors) _nstore_generate_accessors(attribute, flat_accessors, prefix, stringify) end @@ -82,10 +82,12 @@ # @param [Symbol] attribute # @param [Array] keys # @param [Object] value def write_nstore_attribute(attribute, keys, value) + send("#{attribute}=", {}) if send(attribute).nil? position = send(attribute) + keys[0..-2].each do |key| position[key] = {} unless position[key].is_a?(Hash) position = position[key] end position[keys[-1]] = value