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) ⇒ Object
- .json_create(o) ⇒ Object
- .list(params) ⇒ Object
-
.show(o) ⇒ 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(o) ⇒ Assemblies
constructor
A new instance of Assemblies.
- #inputs(arg = []) ⇒ Object
- #name(arg = nil) ⇒ Object
- #org_id(arg = nil) ⇒ Object
- #password(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(o) ⇒ Assemblies
Returns a new instance of Assemblies.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/megam/core/assemblies.rb', line 19 def initialize(o) @id = nil @accounts_id = nil @org_id = nil @name = nil @password = nil @assemblies = [] @inputs = [] @created_at = nil super(o) end |
Class Method Details
.create(params) ⇒ Object
165 166 167 168 |
# File 'lib/megam/core/assemblies.rb', line 165 def self.create(params) asm = from_hash(params) asm.create end |
.from_hash(o) ⇒ Object
148 149 150 151 152 |
# File 'lib/megam/core/assemblies.rb', line 148 def self.from_hash(o) asm = self.new(o) asm.from_hash(o) asm end |
.json_create(o) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/megam/core/assemblies.rb', line 136 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
181 182 183 184 |
# File 'lib/megam/core/assemblies.rb', line 181 def self.list(params) asm = self.new(params) asm.megam_rest.get_assemblies end |
.show(o) ⇒ Object
Load a account by email_p
176 177 178 179 |
# File 'lib/megam/core/assemblies.rb', line 176 def self.show(o) asm = self.new(o) asm.megam_rest.get_one_assemblies(o[: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
31 32 33 |
# File 'lib/megam/core/assemblies.rb', line 31 def assemblies self end |
#create ⇒ Object
Create the node via the REST API
171 172 173 |
# File 'lib/megam/core/assemblies.rb', line 171 def create megam_rest.post_assemblies(to_hash) end |
#created_at(arg = nil) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/megam/core/assemblies.rb', line 91 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
99 100 101 |
# File 'lib/megam/core/assemblies.rb', line 99 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/megam/core/assemblies.rb', line 123 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
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/megam/core/assemblies.rb', line 154 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
83 84 85 86 87 88 89 |
# File 'lib/megam/core/assemblies.rb', line 83 def inputs(arg=[]) if arg != [] @inputs = arg else @inputs end end |
#name(arg = nil) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/megam/core/assemblies.rb', line 67 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 |
#password(arg = nil) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/megam/core/assemblies.rb', line 59 def password(arg=nil) if arg != nil @password = arg else @password end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/megam/core/assemblies.rb', line 104 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.
119 120 121 |
# File 'lib/megam/core/assemblies.rb', line 119 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
186 187 188 |
# File 'lib/megam/core/assemblies.rb', line 186 def to_s Megam::Stuff.styled_hash(to_hash) end |