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



85
86
87
# File 'lib/stall/config.rb', line 85

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

#default_currency_as_moneyObject Also known as: default_currency



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

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

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



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

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

#omniauth_providersObject



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

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



118
119
120
# File 'lib/stall/config.rb', line 118

def omniauth_providers_configs
  @omniauth_providers_configs ||= {}
end

#paymentObject



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

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



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/stall/config.rb', line 94

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



106
107
108
# File 'lib/stall/config.rb', line 106

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

#shippingObject



69
70
71
# File 'lib/stall/config.rb', line 69

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

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



77
78
79
80
81
82
83
# File 'lib/stall/config.rb', line 77

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