class Flowthings::Client
Public Class Methods
new(options={})
click to toggle source
# File lib/flowthings/client.rb, line 17 def initialize(options={}) @services = [ApiTask, Drop, Flow, Group, Identity, Mqtt, Share, Token, Track] merged_options = Flowthings.options.merge options Configuration::VALID_CONFIG_KEYS.each do |key| send "#{key}=", merged_options[key] end service_factory end
Private Instance Methods
get_options()
click to toggle source
# File lib/flowthings/client.rb, line 29 def get_options opts = {} Configuration::VALID_CONFIG_KEYS.each do |key| opts[key.to_sym] = send "#{key}" end opts end
service_factory()
click to toggle source
# File lib/flowthings/client.rb, line 38 def service_factory @services.each do |service| # service.name.underscore looks like this: flowthings/api_importer # so, I have to split it like that. service_name = service.name.underscore.split("/")[1] if service_name == "drop" instance_eval <<-EOS def #{service_name}(flow_id=nil) #{service}.new flow_id, connection, get_options end EOS else instance_eval <<-EOS def #{service_name} #{service}.new connection, get_options end EOS end end end