Module: Apiotics

Defined in:
lib/apiotics/insert.rb,
lib/apiotics.rb,
lib/apiotics/parse.rb,
lib/apiotics/client.rb,
lib/apiotics/portal.rb,
lib/apiotics/server.rb,
lib/apiotics/extract.rb,
lib/apiotics/railtie.rb,
lib/apiotics/version.rb,
lib/apiotics/hardware.rb,
lib/apiotics/configuration.rb,
lib/generators/apiotics/view/view_generator.rb,
lib/generators/apiotics/model/model_generator.rb,
lib/generators/apiotics/script/script_generator.rb,
lib/generators/apiotics/channel/channel_generator.rb,
lib/generators/apiotics/install/install_generator.rb,
lib/generators/apiotics/scaffold/scaffold_generator.rb,
lib/generators/apiotics/migration/migration_generator.rb,
lib/generators/apiotics/controller/controller_generator.rb,
lib/generators/apiotics/initializer/initializer_generator.rb,
lib/generators/apiotics/create_model/create_model_generator.rb,
lib/generators/apiotics/create_table/create_table_generator.rb

Overview

This class takes ruby hashes and saves them to the appropriate database table. All model methods that have corresponding IoT interfaces have six database fields associated with them. The first is a field named the same as the method. The second is name_ack, and third is name_complete, the fourth is name_timestamp, the fifth is name_status, the sixth is name_action. In the hash, instance is the record id (not necessarily the id column), driver is the model, interface is the method. Data should be saved both to the model’s database table and to the corresponding log table (name_method_logs).

Defined Under Namespace

Classes: ChannelGenerator, Client, Configuration, ControllerGenerator, CreateModelGenerator, CreateTableGenerator, Extract, Hardware, InitializerGenerator, Insert, InstallGenerator, MigrationGenerator, ModelGenerator, Parse, Portal, Railtie, ScaffoldGenerator, ScriptGenerator, Server, ViewGenerator

Constant Summary collapse

VERSION =
'0.1.65'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



15
16
17
# File 'lib/apiotics.rb', line 15

def configuration
  @configuration
end

Class Method Details

.clear_settingsObject



54
55
56
# File 'lib/apiotics.rb', line 54

def self.clear_settings
  ApioticsSetting.destroy_all
end

.configure {|configuration| ... } ⇒ Object

Yields:



26
27
28
# File 'lib/apiotics.rb', line 26

def self.configure
  yield(configuration)
end

.get(object, time0 = nil, time1 = nil) ⇒ Object



30
31
32
# File 'lib/apiotics.rb', line 30

def self.get(object, time0= nil, time1= nil)
  Apiotics::Extract.get(object, time0, time1)
end

.get_attributes(parent_name, model_name) ⇒ Object



34
35
36
37
# File 'lib/apiotics.rb', line 34

def self.get_attributes(parent_name, model_name)
  configuration = Apiotics::Portal.retrieve_configuration
  attributes = Apiotics::Portal.parse_drivers_and_scripts(configuration, parent_name, model_name)
end

.resetObject



22
23
24
# File 'lib/apiotics.rb', line 22

def self.reset
  @configuration = Configuration.new
end

.sync(object) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/apiotics.rb', line 43

def self.sync(object)
  parent = object.class.parent.name
  child = object.class.name.demodulize
  attributes = Apiotics.configuration.targets[parent][child]
  interfaces = Hash.new
  attributes.each do |attribute|
    interfaces[attribute.underscore.downcase.gsub(" ", "_")] = object.send(attribute.underscore.downcase.gsub(" ", "_")).to_s
  end
  Apiotics::Extract.fire(object, interfaces, "get")
end

.sync_device_instances(worker_name, sync_data = false) ⇒ Object



39
40
41
# File 'lib/apiotics.rb', line 39

def self.sync_device_instances(worker_name, sync_data= false)
  Apiotics::Portal.sync_device_instances(worker_name, sync_data)
end