Class: Megam::Assemblies
- Inherits:
-
RestAdapter
- Object
- RestAdapter
- Megam::Assemblies
- Defined in:
- lib/megam/core/assemblies.rb
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
- #some_msg(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
Constructor Details
#initialize(o) ⇒ Assemblies
Returns a new instance of Assemblies.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/megam/core/assemblies.rb', line 3 def initialize(o) @id = nil @accounts_id = nil @org_id = nil @name = nil @password = nil @assemblies = [] @inputs = [] @created_at = nil @some_msg = {} 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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/megam/core/assemblies.rb', line 132 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.some_msg[:code] = o["code"] if o.has_key?("code") asm.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") asm.some_msg[:msg]= o["msg"] if o.has_key?("msg") asm.some_msg[:links] = o["links"] if o.has_key?("links") 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
28 29 30 31 32 33 34 |
# File 'lib/megam/core/assemblies.rb', line 28 def accounts_id(arg=nil) if arg != nil @accounts_id = arg else @accounts_id end end |
#assemblies(arg = []) ⇒ Object
16 17 18 |
# File 'lib/megam/core/assemblies.rb', line 16 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
76 77 78 79 80 81 82 |
# File 'lib/megam/core/assemblies.rb', line 76 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
84 85 86 |
# File 'lib/megam/core/assemblies.rb', line 84 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/megam/core/assemblies.rb', line 119 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
20 21 22 23 24 25 26 |
# File 'lib/megam/core/assemblies.rb', line 20 def id(arg=nil) if arg != nil @id = arg else @id end end |
#inputs(arg = []) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/megam/core/assemblies.rb', line 68 def inputs(arg=[]) if arg != [] @inputs = arg else @inputs end end |
#name(arg = nil) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/megam/core/assemblies.rb', line 52 def name(arg=nil) if arg != nil @name = arg else @name end end |
#org_id(arg = nil) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/megam/core/assemblies.rb', line 36 def org_id(arg=nil) if arg != nil @org_id = arg else @org_id end end |
#password(arg = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/megam/core/assemblies.rb', line 44 def password(arg=nil) if arg != nil @password = arg else @password end end |
#some_msg(arg = nil) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/megam/core/assemblies.rb', line 89 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/megam/core/assemblies.rb', line 99 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["some_msg"] = some_msg index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
115 116 117 |
# File 'lib/megam/core/assemblies.rb', line 115 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 |