Class: Megam::Assemblies
- Defined in:
- lib/megam/core/assemblies.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .json_create(o) ⇒ Object
- .list(tmp_email = nil, tmp_api_key = nil, inflated = false) ⇒ Object
-
.show(one_assemblies_id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #accounts_id(arg = nil) ⇒ Object
- #assemblies(arg = []) ⇒ Object
-
#create ⇒ Object
Create the node via the REST API.
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil) ⇒ Assemblies
constructor
A new instance of Assemblies.
- #inputs(arg = []) ⇒ Object
- #name(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil) ⇒ Assemblies
Returns a new instance of Assemblies.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/megam/core/assemblies.rb', line 19 def initialize(email=nil, api_key=nil) @id = nil @accounts_id = nil @name = nil @assemblies = [] @assemblies_type = [] @inputs = {} @label = nil @cloudsettings = [] @created_at = nil super(email, api_key) end |
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
154 155 156 157 |
# File 'lib/megam/core/assemblies.rb', line 154 def self.create(o,tmp_email=nil, tmp_api_key=nil) asm = from_hash(o, tmp_email, tmp_api_key) asm.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
137 138 139 140 141 |
# File 'lib/megam/core/assemblies.rb', line 137 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil) asm = self.new(tmp_email, tmp_api_key) asm.from_hash(o) asm end |
.json_create(o) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/megam/core/assemblies.rb', line 121 def self.json_create(o) asm = new asm.id(o["id"]) if o.has_key?("id") asm.name(o["name"]) if o.has_key?("name") asm.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id") asm.assemblies(o["assemblies"]) if o.has_key?("assemblies") #this will be an array? can hash store array? oq = o["inputs"] asm.inputs[:id] = oq["id"] if oq && oq.has_key?("id") asm.inputs[:assemblies_type] = oq["assemblies_type"] if oq && oq.has_key?("assemblies_type") asm.inputs[:label] = oq["label"] if oq && oq.has_key?("label") asm.inputs[:cloudsettings] = oq["cloudsettings"] if oq && oq.has_key?("cloudsettings") asm.created_at(o["created_at"]) if o.has_key?("created_at") asm end |
.list(tmp_email = nil, tmp_api_key = nil, inflated = false) ⇒ Object
170 171 172 173 |
# File 'lib/megam/core/assemblies.rb', line 170 def self.list(tmp_email=nil, tmp_api_key=nil, inflated=false) asm = self.new(tmp_email, tmp_api_key) asm.megam_rest.get_assemblies end |
.show(one_assemblies_id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Load a account by email_p
165 166 167 168 |
# File 'lib/megam/core/assemblies.rb', line 165 def self.show(one_assemblies_id, tmp_email=nil, tmp_api_key=nil) asm = self.new(tmp_email, tmp_api_key) asm.megam_rest.get_one_assemblies(one_assemblies_id) end |
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/megam/core/assemblies.rb', line 45 def accounts_id(arg=nil) if arg != nil @accounts_id = arg else @accounts_id end end |
#assemblies(arg = []) ⇒ Object
32 33 34 |
# File 'lib/megam/core/assemblies.rb', line 32 def assemblies self end |
#create ⇒ Object
Create the node via the REST API
160 161 162 |
# File 'lib/megam/core/assemblies.rb', line 160 def create megam_rest.post_assemblies(to_hash) end |
#created_at(arg = nil) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/megam/core/assemblies.rb', line 78 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
86 87 88 |
# File 'lib/megam/core/assemblies.rb', line 86 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/megam/core/assemblies.rb', line 109 def for_json result = { "id" => id, "name" => name, "accounts_id" => accounts_id, "assemblies" => assemblies, "inputs" => inputs, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/megam/core/assemblies.rb', line 143 def from_hash(o) @id = o["id"] if o.has_key?("id") @name = o["name"] if o.has_key?("name") @accounts_id = o["accounts_id"] if o.has_key?("accounts_id") @assemblies = o["assemblies"] if o.has_key?("assemblies") @inputs = o["inputs"] if o.has_key?("inputs") @label = o["label"] if o.has_key?("label") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/megam/core/assemblies.rb', line 37 def id(arg=nil) if arg != nil @id = arg else @id end end |
#inputs(arg = []) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/megam/core/assemblies.rb', line 70 def inputs(arg=[]) if arg != [] @inputs = arg else @inputs end end |
#name(arg = nil) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/megam/core/assemblies.rb', line 53 def name(arg=nil) if arg != nil @name = arg else @name end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/megam/core/assemblies.rb', line 91 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["name"] = name index_hash["accounts_id"] = accounts_id index_hash["inputs"] = inputs index_hash["assemblies"] = assemblies index_hash["created_at"] = created_at index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
105 106 107 |
# File 'lib/megam/core/assemblies.rb', line 105 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
175 176 177 |
# File 'lib/megam/core/assemblies.rb', line 175 def to_s Megam::Stuff.styled_hash(to_hash) end |