Class: ArcWeld::Reference
- Inherits:
-
Object
- Object
- ArcWeld::Reference
- Defined in:
- lib/arc_weld/reference.rb
Instance Attribute Summary collapse
-
#externalID ⇒ Object
Returns the value of attribute externalID.
-
#id ⇒ Object
Returns the value of attribute id.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #identity ⇒ Object
- #identity_hash ⇒ Object
-
#initialize(*args) ⇒ Reference
constructor
A new instance of Reference.
- #ref ⇒ Object
- #render ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(*args) ⇒ Reference
Returns a new instance of Reference.
5 6 7 8 |
# File 'lib/arc_weld/reference.rb', line 5 def initialize(*args) Hash[*args].each {|k,v| self.send(format('%s=',k),v)} @type ||= 'Group' end |
Instance Attribute Details
#externalID ⇒ Object
Returns the value of attribute externalID.
3 4 5 |
# File 'lib/arc_weld/reference.rb', line 3 def externalID @externalID end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/arc_weld/reference.rb', line 3 def id @id end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/arc_weld/reference.rb', line 3 def type @type end |
#uri ⇒ Object
Returns the value of attribute uri.
3 4 5 |
# File 'lib/arc_weld/reference.rb', line 3 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 17 18 |
# File 'lib/arc_weld/reference.rb', line 14 def ==(other) [:type, :uri, :id, :externalID].all? do |attr| self.send(attr) == other.send(attr) end end |
#identity ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/arc_weld/reference.rb', line 28 def identity if id!=nil {:id => id} elsif externalID!=nil {:externalID => externalID} else {} end end |
#identity_hash ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/arc_weld/reference.rb', line 20 def identity_hash if identity=={} {} else Hash[identity.keys.map {|k| format('@%s',k.to_s)}.zip(identity.values)] end end |
#ref ⇒ Object
10 11 12 |
# File 'lib/arc_weld/reference.rb', line 10 def ref self end |
#render ⇒ Object
47 48 49 |
# File 'lib/arc_weld/reference.rb', line 47 def render Gyoku.xml(to_h, key_converter: :none) end |
#to_h ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/arc_weld/reference.rb', line 38 def to_h { 'ref/' => { :@type => type, :@uri => uri }.merge(identity_hash) } end |