Class: Spree::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::Base
- Defined in:
- app/models/spree/base.rb
Direct Known Subclasses
Solidus::Migrations::PromotionWithCodeHandlers::PromotionCode, Address, Adjustment, AdjustmentReason, Asset, Calculator, Carton, Classification, Country, CustomerReturn, InventoryUnit, LegacyUser, LineItem, LineItemAction, LogEntry, OptionType, OptionValue, OptionValuesVariant, Order, OrderMutex, OrderPromotion, Payment, PaymentCaptureEvent, PaymentMethod, PaymentSource, Preference, Price, Product, ProductOptionType, ProductPromotionRule, ProductProperty, Promotion, PromotionAction, PromotionCategory, PromotionCode, PromotionCodeBatch, PromotionRule, PromotionRuleRole, PromotionRuleStore, PromotionRuleTaxon, PromotionRuleUser, Property, Refund, RefundReason, Reimbursement, Reimbursement::Credit, ReimbursementType, ReturnAuthorization, ReturnItem, ReturnReason, Role, RoleUser, Shipment, ShippingCategory, ShippingMethod, ShippingMethodCategory, ShippingMethodStockLocation, ShippingMethodZone, ShippingRate, ShippingRateTax, State, StateChange, StockItem, StockLocation, StockMovement, Store, StoreCreditCategory, StoreCreditEvent, StoreCreditReason, StoreCreditType, StorePaymentMethod, StoreShippingMethod, TaxCategory, TaxRate, TaxRateTaxCategory, Taxon, Taxonomy, UnitCancel, UserAddress, UserStockLocation, Variant, VariantPropertyRule, VariantPropertyRuleCondition, VariantPropertyRuleValue, WalletPaymentSource, Zone, ZoneMember
Class Method Summary collapse
-
.display_includes ⇒ Object
Provides a scope that should be included any time products are fetched with the intention of displaying to the user.
- .page(num) ⇒ Object
-
.preference(*args) ⇒ Object
Only run preference initialization on models which requires it.
- .preferences_coder_class ⇒ Object
Instance Method Summary collapse
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Methods included from Preferences::Preferable
#admin_form_preference_names, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.display_includes ⇒ Object
Provides a scope that should be included any time products are fetched with the intention of displaying to the user.
Allows individual stores to include any active record scopes or joins when products are displayed.
49 50 51 |
# File 'app/models/spree/base.rb', line 49 def self.display_includes where(nil) end |
.page(num) ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/models/spree/base.rb', line 29 def self.page(num) Spree::Deprecation.warn \ "Redefining Spree::Base.page for a different kaminari page name is better done inside " \ "your own app. This will be removed from future versions of solidus." send Kaminari.config.page_method_name, num end |
.preference(*args) ⇒ Object
Only run preference initialization on models which requires it. Improves performance of record initialization slightly.
20 21 22 23 24 25 26 |
# File 'app/models/spree/base.rb', line 20 def self.preference(*args) # after_initialize can be called multiple times with the same symbol, it # will only be called once on initialization. serialize :preferences, preferences_coder_class after_initialize :initialize_preference_defaults super end |
.preferences_coder_class ⇒ Object
38 39 40 |
# File 'app/models/spree/base.rb', line 38 def self.preferences_coder_class Hash end |
Instance Method Details
#initialize_preference_defaults ⇒ Object
12 13 14 15 16 |
# File 'app/models/spree/base.rb', line 12 def initialize_preference_defaults if has_attribute?(:preferences) self.preferences = default_preferences.merge(preferences) end end |
#preferences ⇒ Object
8 9 10 |
# File 'app/models/spree/base.rb', line 8 def preferences read_attribute(:preferences) || self.class.preferences_coder_class.new end |