Sha256: fd1b22efab00b3eb4bea8077f918228d392a95382bc3a7691ada6cce47ab9198

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

require_relative "subscription"

module Vindi
  # Customers
  #
  # @example
  #
  #   customer = Vindi::Customer.find(1)
  #   customer.subscriptions
  #   customer.subscriptions.active
  #
  #   customer = Vindi::Customer.find_by(email: "gandalf@middleearth.com")
  #   customer.name
  #   customer.name = "Gandalf the White"
  #   customer.save
  #
  class Customer < Model
    scope :contains_name, ->(name) { where(contains: { name: name }) }

    has_one :address, class_name: "Vindi::Address"
    # has_many :subscriptions, class_name: "Vindi::Subscription", parent_as_param: true, group_params_with: :query

    def subscriptions
      Vindi::Subscription.where(customer_id: id)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rvindi-0.0.3 lib/vindi/models/customer.rb
vindi-hermes-0.0.2 lib/vindi/models/customer.rb
vindi-hermes-0.0.1 lib/vindi/models/customer.rb