Class: Megam::Assembly
- Defined in:
- lib/megam/core/assembly.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .json_create(o) ⇒ Object
- .show(assembly_id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Instance Method Summary collapse
- #assembly ⇒ Object
- #components(arg = []) ⇒ Object
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil) ⇒ Assembly
constructor
A new instance of Assembly.
- #inputs(arg = []) ⇒ Object
- #name(arg = nil) ⇒ Object
- #operations(arg = nil) ⇒ Object
- #policies(arg = []) ⇒ 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) ⇒ Assembly
Returns a new instance of Assembly.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/megam/core/assembly.rb', line 19 def initialize(email=nil, api_key=nil) @id = nil @name = nil @components = [] @policies={} @inputs = {} @operations = nil @created_at = nil super(email, api_key) end |
Class Method Details
.from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
140 141 142 143 144 |
# File 'lib/megam/core/assembly.rb', line 140 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
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/megam/core/assembly.rb', line 128 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.components(o["components"]) if o.has_key?("components") asm.policies(o["policies"]) if o.has_key?("policies") #this will be an array? can hash store array? asm.inputs(o["inputs"]) if o.has_key?("inputs") asm.operations(o["operations"]) if o.has_key?("operations") asm.created_at(o["created_at"]) if o.has_key?("created_at") asm end |
.show(assembly_id, tmp_email = nil, tmp_api_key = nil) ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/megam/core/assembly.rb', line 158 def self.show(assembly_id, tmp_email=nil, tmp_api_key=nil) asm = self.new(tmp_email, tmp_api_key) puts "---->>>> " puts #{assembly_id} puts "----------->>>" asm.megam_rest.get_one_assembly(assembly_id) end |
Instance Method Details
#assembly ⇒ Object
30 31 32 |
# File 'lib/megam/core/assembly.rb', line 30 def assembly self end |
#components(arg = []) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/megam/core/assembly.rb', line 50 def components(arg=[]) if arg != [] @components = arg else @components end end |
#created_at(arg = nil) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/megam/core/assembly.rb', line 82 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
90 91 92 |
# File 'lib/megam/core/assembly.rb', line 90 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/megam/core/assembly.rb', line 114 def for_json result = { "id" => id, "name" => name, "components" => components, "policies" => policies, "inputs" => inputs, "operations" => operations, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/megam/core/assembly.rb', line 146 def from_hash(o) @id = o["id"] if o.has_key?("id") @name = o["name"] if o.has_key?("name") @components = o["components"] if o.has_key?("components") @policies = o["policies"] if o.has_key?("policies") @inputs = o["inputs"] if o.has_key?("inputs") @operations = o["operations"] if o.has_key?("operations") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/megam/core/assembly.rb', line 34 def id(arg=nil) if arg != nil @id = arg else @id end end |
#inputs(arg = []) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/megam/core/assembly.rb', line 66 def inputs(arg=[]) if arg != [] @inputs = arg else @inputs end end |
#name(arg = nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/megam/core/assembly.rb', line 42 def name(arg=nil) if arg != nil @name = arg else @name end end |
#operations(arg = nil) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/megam/core/assembly.rb', line 74 def operations(arg=nil) if arg != nil @operations = arg else @operations end end |
#policies(arg = []) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/megam/core/assembly.rb', line 58 def policies(arg=[]) if arg != [] @policies = arg else @policies end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/megam/core/assembly.rb', line 95 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["name"] = name index_hash["components"] = components index_hash["policies"] = policies index_hash["inputs"] = inputs index_hash["operations"] = operations 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.
110 111 112 |
# File 'lib/megam/core/assembly.rb', line 110 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
167 168 169 |
# File 'lib/megam/core/assembly.rb', line 167 def to_s Megam::Stuff.styled_hash(to_hash) end |