Module: Fera::HasSubject::ClassMethods

Defined in:
lib/fera/models/concerns/has_subject.rb

Instance Method Summary collapse

Instance Method Details

#for_product(product_id) ⇒ Object



16
17
18
# File 'lib/fera/models/concerns/has_subject.rb', line 16

def for_product(product_id)
  for_products(product_id).try(:first)
end

#for_products(product_ids = nil) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/fera/models/concerns/has_subject.rb', line 8

def for_products(product_ids = nil)
  if product_ids.present?
    where(product_id: product_ids)
  else
    where(subject: :product)
  end
end

#for_storeObject



20
21
22
# File 'lib/fera/models/concerns/has_subject.rb', line 20

def for_store
  all.where(subject: :store).try(:first)
end