Class: Opushon::RestrictedValue Private
- Inherits:
-
Object
- Object
- Opushon::RestrictedValue
- 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
- #description ⇒ Object readonly private
- #title ⇒ Object readonly private
- #value ⇒ Object readonly private
Class Method Summary collapse
- .load(hash) ⇒ Object private
Instance Method Summary collapse
-
#initialize(title: '', description: '', value:) ⇒ RestrictedValue
constructor
private
A new instance of RestrictedValue.
- #to_h ⇒ Object private
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.
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
#description ⇒ Object (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 |
#title ⇒ Object (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 |
#value ⇒ Object (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.
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_h ⇒ 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.
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 |