Sha256: 51441d4ef70fead644bbe8201759a1de2f98ee80476864a745f4628aa30b5ca9
Contents?: true
Size: 991 Bytes
Versions: 22
Compression:
Stored size: 991 Bytes
Contents
module Spree module CalculatedAdjustments extend ActiveSupport::Concern included do has_one :calculator, class_name: 'Spree::Calculator', as: :calculable, inverse_of: :calculable, dependent: :destroy, autosave: true accepts_nested_attributes_for :calculator validates :calculator, presence: true delegate :compute, to: :calculator def self.calculators spree_calculators.send model_name_without_spree_namespace end def calculator_type calculator.class.to_s if calculator end def calculator_type=(calculator_type) klass = calculator_type.constantize if calculator_type self.calculator = klass.new if klass && !calculator.instance_of?(klass) end private def self.model_name_without_spree_namespace to_s.tableize.tr('/', '_').sub('spree_', '') end def self.spree_calculators Rails.application.config.spree.calculators end end end end
Version data entries
22 entries across 22 versions & 1 rubygems