Class: Stall::Config

Inherits:
Object
  • Object
show all
Extended by:
Utils::ConfigDSL
Defined in:
lib/stall/config.rb

Instance Method Summary collapse

Methods included from Utils::ConfigDSL

param

Instance Method Details

#default_app_domainObject



89
90
91
# File 'lib/stall/config.rb', line 89

def default_app_domain
  @default_app_domain || ENV['APP_DOMAIN']
end

#default_currency_as_moneyObject Also known as: default_currency



114
115
116
# File 'lib/stall/config.rb', line 114

def default_currency_as_money
  raw_default_currency && Money::Currency.new(raw_default_currency)
end

#omniauth_provider(name, config = {}) ⇒ Object



126
127
128
# File 'lib/stall/config.rb', line 126

def omniauth_provider(name, config = {})
  omniauth_providers_configs[name] = config
end

#omniauth_providersObject



130
131
132
133
134
# File 'lib/stall/config.rb', line 130

def omniauth_providers
  omniauth_providers_configs.map do |provider, config|
    Stall::OmniauthProvider.new(provider, config.deep_dup)
  end
end

#omniauth_providers_configsObject

User omniauth providers



122
123
124
# File 'lib/stall/config.rb', line 122

def omniauth_providers_configs
  @omniauth_providers_configs ||= {}
end

#paymentObject



77
78
79
# File 'lib/stall/config.rb', line 77

def payment
  @payment ||= Stall::Payments::Config.new
end

#service_for(identifier) ⇒ Object

Fetch user config and add top-namespace lookup to avoid collision with Stall module services.

Default allows looking up Stall namespace automatically, when no config has been given



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/stall/config.rb', line 98

def service_for(identifier)
  class_name = if (service_name = services[identifier])
    "::#{ services[identifier].gsub(/^::/, '') }"
  elsif File.exists?(Rails.root.join('app', 'services', "#{ identifier }_service.rb"))
    "::#{ identifier.to_s.camelize }Service"
  else
    "Stall::#{ identifier.to_s.camelize }Service"
  end

  class_name.constantize
end

#services=(value) ⇒ Object



110
111
112
# File 'lib/stall/config.rb', line 110

def services=(value)
  self.services.merge!(value)
end

#shippingObject



73
74
75
# File 'lib/stall/config.rb', line 73

def shipping
  @shipping ||= Stall::Shipping::Config.new
end

#steps_initialization(value = nil, &block) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/stall/config.rb', line 81

def steps_initialization(value = nil, &block)
  if (value ||= block)
    @_steps_initialization_callback = value
  else
    @_steps_initialization_callback
  end
end