Class: AgentClientProtocol::Types::Scalar
- Inherits:
-
Object
- Object
- AgentClientProtocol::Types::Scalar
- Defined in:
- lib/agent_client_protocol/types/base.rb
Class Attribute Summary collapse
-
.coercer ⇒ Object
readonly
Returns the value of attribute coercer.
-
.definition_name ⇒ Object
readonly
Returns the value of attribute definition_name.
-
.schema ⇒ Object
readonly
Returns the value of attribute schema.
-
.unstable ⇒ Object
readonly
Returns the value of attribute unstable.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .coerce(value) ⇒ Object
- .configure(definition_name:, schema:, unstable: false, coercer: nil) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(value) ⇒ Scalar
constructor
A new instance of Scalar.
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(value) ⇒ Scalar
Returns a new instance of Scalar.
290 291 292 293 |
# File 'lib/agent_client_protocol/types/base.rb', line 290 def initialize(value) @value = value freeze end |
Class Attribute Details
.coercer ⇒ Object (readonly)
Returns the value of attribute coercer.
270 271 272 |
# File 'lib/agent_client_protocol/types/base.rb', line 270 def coercer @coercer end |
.definition_name ⇒ Object (readonly)
Returns the value of attribute definition_name.
270 271 272 |
# File 'lib/agent_client_protocol/types/base.rb', line 270 def definition_name @definition_name end |
.schema ⇒ Object (readonly)
Returns the value of attribute schema.
270 271 272 |
# File 'lib/agent_client_protocol/types/base.rb', line 270 def schema @schema end |
.unstable ⇒ Object (readonly)
Returns the value of attribute unstable.
270 271 272 |
# File 'lib/agent_client_protocol/types/base.rb', line 270 def unstable @unstable end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
288 289 290 |
# File 'lib/agent_client_protocol/types/base.rb', line 288 def value @value end |
Class Method Details
.coerce(value) ⇒ Object
280 281 282 283 284 285 |
# File 'lib/agent_client_protocol/types/base.rb', line 280 def coerce(value) return value if value.is_a?(self) normalized = coercer.nil? ? value : coercer.call(value) new(normalized) end |
.configure(definition_name:, schema:, unstable: false, coercer: nil) ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/agent_client_protocol/types/base.rb', line 272 def configure(definition_name:, schema:, unstable: false, coercer: nil) @definition_name = definition_name @schema = schema @unstable = unstable @coercer = coercer freeze end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
303 304 305 |
# File 'lib/agent_client_protocol/types/base.rb', line 303 def ==(other) other.is_a?(self.class) && other.value == value end |
#hash ⇒ Object
309 310 311 |
# File 'lib/agent_client_protocol/types/base.rb', line 309 def hash [self.class, value].hash end |
#to_h ⇒ Object
295 296 297 |
# File 'lib/agent_client_protocol/types/base.rb', line 295 def to_h value end |
#to_json(*args) ⇒ Object
299 300 301 |
# File 'lib/agent_client_protocol/types/base.rb', line 299 def to_json(*args) value.to_json(*args) end |