Sha256: e3e6b718ee3a564ff1f4b9558c68792013ede1dbb16a8f6482575a285100970b

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 Bytes

Contents

module Spree
  module ActiveShipping
    # Singleton class to access the shipping configuration object (ActiveShippingConfiguration.first by default) and it's preferences.
    #
    # Usage:
    #   Spree::ActiveShipping::Config[:foo]                  # Returns the foo preference
    #   Spree::ActiveShipping::Config[]                      # Returns a Hash with all the tax preferences
    #   Spree::ActiveShipping::Config.instance               # Returns the configuration object (ActiveShippingConfiguration.first)
    #   Spree::ActiveShipping::Config.set(preferences_hash)  # Set the active shipping preferences as especified in +preference_hash+
    class Config
      include Singleton
      include PreferenceAccess
    
      class << self
        def instance
          return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
          ActiveShippingConfiguration.find_or_create_by_name("Default active_shipping configuration")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_active_shipping-1.0.0 lib/spree/active_shipping/config.rb