Module: Fera::HasSubject

Extended by:
ActiveSupport::Concern
Included in:
Media, Rating, Review
Defined in:
lib/fera/models/concerns/has_subject.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#for_product?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fera/models/concerns/has_subject.rb', line 34

def for_product?
  subject.to_s == 'product'
end

#for_store?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/fera/models/concerns/has_subject.rb', line 38

def for_store?
  subject.to_s == 'store'
end

#product::Fera::Product, NilClass

Returns the associated product model if it was preloaded in the original request and if the object is for a product.

Returns:



28
29
30
31
32
# File 'lib/fera/models/concerns/has_subject.rb', line 28

def product
  return nil if attributes['subject'] !~ /^product/i

  super
end