Sha256: 450f8014ed05883ea675f3d6ee4986fe06dab346b2408f169bcecfac8fd9ac17

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

module Charger

  class ProductFamily
    include Resource

    attribute :id, Integer
    attribute :name, String
    attribute :handle, String
    attribute :accounting_code, String
    attribute :description, String

    validates :name,   presence: true
    validates :handle, presence: true

    # @param [Boolean] force will cause this to un-cache the results
    def products force=false
      @products = nil if force
      @products ||= Product.find_by_product_family_id(id)
    end

    # Get all of the components descriptions associated to this product family
    #
    # @param [Boolean] force will cause this to un-cache the results
    # @return [Array<Component>]
    def components force=false
      @components = nil if force
      @components ||= Component.find_by_product_family_id(id)
    end

    def persisted?
      !!id
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
charger-0.2.0 lib/charger/product_family.rb
charger-0.1.1 lib/charger/product_family.rb
charger-0.1.0 lib/charger/product_family.rb
charger-0.0.3 lib/charger/product_family.rb