Module: Fera::HasSubject
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/fera/models/concerns/has_subject.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #for_product? ⇒ Boolean
- #for_store? ⇒ Boolean
-
#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.
Instance Method Details
#for_product? ⇒ 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
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.
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 |