Class: Opushon::RestrictedValue Private

Inherits:
Object
  • Object
show all
Defined in:
lib/opushon/restricted_value.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

If present, the value of restricted_values is an array where each item

contains a hash.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: '', description: '', value:) ⇒ RestrictedValue

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RestrictedValue.

Raises:

  • (ArgumentError)


25
26
27
28
29
30
31
32
33
# File 'lib/opushon/restricted_value.rb', line 25

def initialize(title: '', description: '', value:)
  raise ArgumentError, "title #{title.inspect}"             unless title.is_a?(String)
  raise ArgumentError, "description #{description.inspect}" unless description.is_a?(String)
  raise ArgumentError, "value #{value.inspect}"             unless value.is_a?(BasicObject)

  @title        = title
  @description  = description
  @value        = value
end

Instance Attribute Details

#descriptionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/opushon/restricted_value.rb', line 23

def description
  @description
end

#titleObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/opushon/restricted_value.rb', line 23

def title
  @title
end

#valueObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/opushon/restricted_value.rb', line 23

def value
  @value
end

Class Method Details

.load(hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/opushon/restricted_value.rb', line 7

def self.load(hash)
  raise ArgumentError, "hash #{hash.inspect}" unless hash.is_a?(Hash)

  title       = hash.fetch('title',       nil)
  description = hash.fetch('description', nil)
  value       = hash.fetch('value',       nil)

  hash = {
    title:        title,
    description:  description,
    value:        value
  }.compact

  new(**hash)
end

Instance Method Details

#to_hObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
# File 'lib/opushon/restricted_value.rb', line 35

def to_h
  {
    title:        title,
    description:  description,
    value:        value
  }
end