Class: VCSToolkit::Objects::Object
- Inherits:
-
Object
- Object
- VCSToolkit::Objects::Object
- Extended by:
- Serializable
- Includes:
- Utils::HashableObject
- Defined in:
- lib/vcs_toolkit/objects/object.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#object_type ⇒ Object
readonly
Returns the value of attribute object_type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(id: nil, object_type: :object, named: false, verify_object_id: true, **context) ⇒ Object
constructor
A new instance of Object.
- #named? ⇒ Boolean
Methods included from Serializable
Methods included from Utils::HashableObject
Constructor Details
#initialize(id: nil, object_type: :object, named: false, verify_object_id: true, **context) ⇒ Object
Returns a new instance of Object.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vcs_toolkit/objects/object.rb', line 14 def initialize(id: nil, object_type: :object, named: false, verify_object_id: true, **context) @object_type = object_type.to_sym @named = named if id @id = id raise InvalidObjectError, 'Invalid id' if verify_object_id and not named? and not id_valid? else raise InvalidObjectError, 'Named objects should always specify an id' if named? @id = generate_id end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/vcs_toolkit/objects/object.rb', line 11 def id @id end |
#object_type ⇒ Object (readonly)
Returns the value of attribute object_type.
11 12 13 |
# File 'lib/vcs_toolkit/objects/object.rb', line 11 def object_type @object_type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 |
# File 'lib/vcs_toolkit/objects/object.rb', line 35 def ==(other) id == other.id end |
#hash ⇒ Object
41 42 43 |
# File 'lib/vcs_toolkit/objects/object.rb', line 41 def hash id.hash end |
#named? ⇒ Boolean
31 32 33 |
# File 'lib/vcs_toolkit/objects/object.rb', line 31 def named? @named end |