Module: Chord

Defined in:
lib/chord.rb,
lib/chord/version.rb

Defined Under Namespace

Classes: APIError, Base, ConfigurationError, LineItem, Order, Payment, Product, Role, Subscription, User, Variant

Constant Summary collapse

VERSION =
"0.0.12"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_key ⇒ Object

Returns the value of attribute api_key.



7
8
9
# File 'lib/chord.rb', line 7

def api_key
  @api_key
end

.base_url ⇒ Object

Returns the value of attribute base_url.



6
7
8
# File 'lib/chord.rb', line 6

def base_url
  @base_url
end

Class Method Details

.config(options) ⇒ Object



9
10
11
12
# File 'lib/chord.rb', line 9

def config(options)
  self.base_url = options[:base_url] if options[:base_url]
  self.api_key = options[:api_key] if options[:api_key]
end

.config_from_env ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chord.rb', line 27

def config_from_env
  if ENV['CHORD_BASE_URL'] or ENV['CHORD_API_KEY']
    Chord.config(
      base_url: ENV['CHORD_BASE_URL'],
      api_key: ENV['CHORD_API_KEY']
    )
    true
  else
    false
  end
end

.config_from_file(filepath) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/chord.rb', line 14

def config_from_file(filepath)
  if File.exist?(filepath)
    require 'yaml'
    config = YAML.load(File.read(filepath), symbolize_names: true)
    Chord.config(
      base_url: config[:base_url],
      api_key: config[:api_key]
    )
  else
    false
  end
end