lib/charger/product.rb in charger-0.0.2 vs lib/charger/product.rb in charger-0.0.3

- old
+ new

@@ -1,12 +1,9 @@ module Charger class Product - include Virtus - extend ActiveModel::Naming - include ActiveModel::Conversion - include ActiveModel::Validations + include Resource attribute :id, Integer attribute :price_in_cents, Integer attribute :name, String attribute :handle, String @@ -28,19 +25,22 @@ attribute :created_at, DateTime attribute :updated_at, DateTime attribute :archived_at, DateTime def self.find_by_product_family_id id - client = Client.new products = [] client.get("product_families/#{id}/products") do |data| products << new(data['product']) end products end def persisted? !!id + end + + def self.client + Charger.client end end end