Class: Copyleaks::IdObject
- Inherits:
-
Object
- Object
- Copyleaks::IdObject
- Defined in:
- lib/copyleaks/models/id_object.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #as_json(*_args) ⇒ Object
-
#initialize(id) ⇒ IdObject
constructor
A new instance of IdObject.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(id) ⇒ IdObject
Returns a new instance of IdObject.
28 29 30 31 32 |
# File 'lib/copyleaks/models/id_object.rb', line 28 def initialize(id) raise 'Copyleaks::IdObject - id - id must be of type String' unless id.instance_of?(String) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
26 27 28 |
# File 'lib/copyleaks/models/id_object.rb', line 26 def id @id end |
Instance Method Details
#as_json(*_args) ⇒ Object
34 35 36 37 38 |
# File 'lib/copyleaks/models/id_object.rb', line 34 def as_json(*_args) { id: @id }.select { |_k, v| !v.nil? } end |
#to_json(*options) ⇒ Object
40 41 42 |
# File 'lib/copyleaks/models/id_object.rb', line 40 def to_json(*) as_json(*).to_json(*) end |