Class: Megam::Assemblies
- Defined in:
- lib/megam/core/assemblies.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(params) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .json_create(o) ⇒ Object
- .list(params) ⇒ Object
-
.show(one_assemblies_id, tmp_email = nil, tmp_api_key = nil, tmp_host = 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, host = nil) ⇒ Assemblies
constructor
A new instance of Assemblies.
- #inputs(arg = []) ⇒ Object
- #name(arg = nil) ⇒ Object
- #org_id(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, host = nil) ⇒ Assemblies
Returns a new instance of Assemblies.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/megam/core/assemblies.rb', line 19 def initialize(email=nil, api_key=nil, host=nil) @id = nil @accounts_id = nil @org_id = nil @name = nil @assemblies = [] @inputs = [] @created_at = nil super(email, api_key, host) end |
Class Method Details
.create(params) ⇒ Object
158 159 160 161 |
# File 'lib/megam/core/assemblies.rb', line 158 def self.create(params) asm = from_hash(params, params["email"] || params[:email], params["api_key"] || params[:api_key], params["host"] || params[:host]) asm.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
141 142 143 144 145 |
# File 'lib/megam/core/assemblies.rb', line 141 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) asm = self.new(tmp_email, tmp_api_key, tmp_host) asm.from_hash(o) asm end |
.json_create(o) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/megam/core/assemblies.rb', line 129 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.org_id(o["org_id"]) if o.has_key?("org_id") asm.assemblies(o["assemblies"]) if o.has_key?("assemblies") #this will be an array? can hash store array? asm.inputs(o["inputs"]) if o.has_key?("inputs") asm.created_at(o["created_at"]) if o.has_key?("created_at") asm end |
.list(params) ⇒ Object
174 175 176 177 |
# File 'lib/megam/core/assemblies.rb', line 174 def self.list(params) asm = self.new(params["email"], params["api_key"], params["host"]) asm.megam_rest.get_assemblies end |
.show(one_assemblies_id, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Load a account by email_p
169 170 171 172 |
# File 'lib/megam/core/assemblies.rb', line 169 def self.show(one_assemblies_id, tmp_email=nil, tmp_api_key=nil, tmp_host=nil) asm = self.new(tmp_email, tmp_api_key, tmp_host) asm.megam_rest.get_one_assemblies(one_assemblies_id) end |
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/megam/core/assemblies.rb', line 43 def accounts_id(arg=nil) if arg != nil @accounts_id = arg else @accounts_id end end |
#assemblies(arg = []) ⇒ Object
30 31 32 |
# File 'lib/megam/core/assemblies.rb', line 30 def assemblies self end |
#create ⇒ Object
Create the node via the REST API
164 165 166 |
# File 'lib/megam/core/assemblies.rb', line 164 def create megam_rest.post_assemblies(to_hash) end |
#created_at(arg = nil) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/megam/core/assemblies.rb', line 84 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
92 93 94 |
# File 'lib/megam/core/assemblies.rb', line 92 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/megam/core/assemblies.rb', line 116 def for_json result = { "id" => id, "name" => name, "accounts_id" => accounts_id, "org_id" => org_id, "assemblies" => assemblies, "inputs" => inputs, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/megam/core/assemblies.rb', line 147 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") @org_id = o["org_id"] if o.has_key?("org_id") @assemblies = o["assemblies"] if o.has_key?("assemblies") @inputs = o["inputs"] if o.has_key?("inputs") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/megam/core/assemblies.rb', line 35 def id(arg=nil) if arg != nil @id = arg else @id end end |
#inputs(arg = []) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/megam/core/assemblies.rb', line 76 def inputs(arg=[]) if arg != [] @inputs = arg else @inputs end end |
#name(arg = nil) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/megam/core/assemblies.rb', line 59 def name(arg=nil) if arg != nil @name = arg else @name end end |
#org_id(arg = nil) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/megam/core/assemblies.rb', line 51 def org_id(arg=nil) if arg != nil @org_id = arg else @org_id end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/megam/core/assemblies.rb', line 97 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["org_id"] = org_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.
112 113 114 |
# File 'lib/megam/core/assemblies.rb', line 112 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
179 180 181 |
# File 'lib/megam/core/assemblies.rb', line 179 def to_s Megam::Stuff.styled_hash(to_hash) end |