Class: AgentClientProtocol::Types::Scalar

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_client_protocol/types/base.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

.coercerObject (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_nameObject (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

.schemaObject (readonly)

Returns the value of attribute schema.



270
271
272
# File 'lib/agent_client_protocol/types/base.rb', line 270

def schema
  @schema
end

.unstableObject (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

#valueObject (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

#hashObject



309
310
311
# File 'lib/agent_client_protocol/types/base.rb', line 309

def hash
  [self.class, value].hash
end

#to_hObject



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