Class: ShafClient::Alps::Extension

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf_client/alps/extension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, href: nil, value: nil) ⇒ Extension

Returns a new instance of Extension.



6
7
8
9
10
# File 'lib/shaf_client/alps/extension.rb', line 6

def initialize(id:, href: nil, value: nil)
  @id = id.to_sym
  @href = href
  @value = value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



22
23
24
25
26
27
# File 'lib/shaf_client/alps/extension.rb', line 22

def method_missing(method_name, *args, &block)
  name = method_name.to_s
  return super unless name.end_with? '?'

  id.to_s == name[0..-2]
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



4
5
6
# File 'lib/shaf_client/alps/extension.rb', line 4

def href
  @href
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/shaf_client/alps/extension.rb', line 4

def id
  @id
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/shaf_client/alps/extension.rb', line 4

def value
  @value
end

Instance Method Details

#to_hObject



12
13
14
15
16
17
18
# File 'lib/shaf_client/alps/extension.rb', line 12

def to_h
  {
    id: id,
    href: href,
    value: value,
  }
end