lib/harvesting/models/base.rb in harvesting-0.5.1 vs lib/harvesting/models/base.rb in harvesting-0.6.0

- old
+ new

@@ -7,11 +7,11 @@ attr_reader :harvest_client def initialize(attrs, opts = {}) @models = {} @attributes = attrs.dup - @harvest_client = opts[:harvest_client] || Harvesting::Client.new(opts) + @harvest_client = opts[:harvest_client] || Harvesting::Client.new(**opts) end # It calls `create` or `update` depending on the record's ID. If the ID # is present, then it calls `update`. Otherwise it calls `create` # @@ -63,11 +63,11 @@ # # @param id [Integer] the id of the object to retrieve # @param opts [Hash] options to pass along to the `Harvesting::Client` # instance def self.get(id, opts = {}) - client = opts[:harvest_client] || Harvesting::Client.new(opts) + client = opts[:harvest_client] || Harvesting::Client.new(**opts) self.new({ 'id' => id }, opts).fetch end protected @@ -106,10 +106,10 @@ # # @param opts [Hash] key = symbol that needs to be the same as the one returned by the Harvest API. value = model class for the nested resource. def self.modeled(opts = {}) opts.each do |attribute_name, model| attribute_name_string = attribute_name.to_s - Harvesting::Models::Base.send :define_method, attribute_name_string do + define_method(attribute_name_string) do @models[attribute_name_string] ||= model.new(@attributes[attribute_name_string] || {}, harvest_client: harvest_client) end end end end