lib/chord.rb in chord-0.0.5 vs lib/chord.rb in chord-0.0.6
- old
+ new
@@ -5,24 +5,38 @@
class << self
attr_accessor :base_url
attr_accessor :api_key
def config(options)
- self.base_url = options[:base_url]
- self.api_key = options[:api_key]
+ self.base_url = options[:base_url] if options[:base_url]
+ self.api_key = options[:api_key] if options[:api_key]
end
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
+
+ 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
end
class Base
include HTTParty
@@ -225,9 +239,13 @@
class Role < Base
def self.base_path
'roles'
+ end
+
+ def users
+ attributes['users'].map{ |u| Chord::User.new(u['id'], u) }
end
end
class Subscription < Base