Module: Organizai

Defined in:
lib/organizai.rb,
lib/organizai/api.rb,
lib/organizai/init.rb,
lib/organizai/user.rb,
lib/organizai/coupon.rb,
lib/organizai/consumer.rb,
lib/organizai/provider.rb,
lib/organizai/response.rb,
lib/generators/organizai/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Api, Consumer, Coupon, Engine, Provider, Response, User

Constant Summary collapse

HOST =

API hosts

{
  :production => "api.organizai.com.br",
  :sandbox    => "sandbox.organizai.com.br"
}
@@consumers =
ActiveSupport::OrderedHash.new
@@format =
:json
@@protocol =
:http
@@configured =

Whether Organizai.config was called or not

false

Class Method Summary collapse

Class Method Details

.api_envObject

Current api env



62
63
64
# File 'lib/organizai.rb', line 62

def self.api_env
  current_consumer.kind
end

.config {|_self| ... } ⇒ Object

Setup

Yields:

  • (_self)

Yield Parameters:

  • _self (Organizai)

    the object that the method was called on



39
40
41
42
43
# File 'lib/organizai.rb', line 39

def self.config
  yield self
  @@configured = true
  raise "Missing consumer config for Organizaí" if @@consumers.empty?
end

.configured?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/organizai.rb', line 45

def self.configured?
  @@configured
end

.consumer(env, &block) ⇒ Object

Used by #config to add consumers configuration



50
51
52
53
54
# File 'lib/organizai.rb', line 50

def self.consumer env, &block
  consumer = Organizai::Consumer.new
  consumer.instance_eval(&block)
  @@consumers[env] = consumer
end

.current_consumerObject

Current consumer by app env



67
68
69
70
71
# File 'lib/organizai.rb', line 67

def self.current_consumer
  consumer = @@consumers[env]
  raise "Missing consumer config for '#{env}' environment." if consumer.nil?
  consumer
end

.envObject

App env



57
58
59
# File 'lib/organizai.rb', line 57

def self.env
  defined?(::Rails) ? ::Rails.env.to_sym : :development
end