Class: ShafClient::Curie
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, href:, templated: nil) ⇒ Curie
constructor
A new instance of Curie.
- #resolve_templated(**args) ⇒ Object
- #to_h ⇒ Object
Methods inherited from Link
Constructor Details
#initialize(name:, href:, templated: nil) ⇒ Curie
Returns a new instance of Curie.
19 20 21 22 23 |
# File 'lib/shaf_client/curie.rb', line 19 def initialize(name:, href:, templated: nil) @name = name @href = href @templated = !!templated end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/shaf_client/curie.rb', line 7 def name @name end |
Class Method Details
.from(data) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/shaf_client/curie.rb', line 9 def self.from(data) if data.is_a? Array data.map do |d| new(name: data['name'], href: d['href'], templated: d['templated']) end else new(name: data['name'], href: data['href'], templated: data['templated']) end end |
Instance Method Details
#resolve_templated(**args) ⇒ Object
25 26 27 28 |
# File 'lib/shaf_client/curie.rb', line 25 def resolve_templated(**args) args[:rel] &&= args[:rel].to_s.sub(/#{name}:/, '') super(**args) end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/shaf_client/curie.rb', line 30 def to_h {name: name}.merge(super) end |