Class: Arbetsformedlingen::Packet
- Inherits:
-
Model
- Object
- Model
- Arbetsformedlingen::Packet
show all
- Defined in:
- lib/arbetsformedlingen/models/packet.rb
Constant Summary
collapse
- DEFAULT_PACKET_ID =
1
Instance Attribute Summary
Attributes inherited from Model
#schema
Instance Method Summary
collapse
Methods inherited from Model
#errors, from_schema, #valid?
Constructor Details
#initialize(attributes:, publication:, document:, position:) ⇒ Packet
Returns a new instance of Packet.
25
26
27
28
29
30
31
32
|
# File 'lib/arbetsformedlingen/models/packet.rb', line 25
def initialize(attributes:, publication:, document:, position:)
hash = attributes
@publication = publication
@document = document
@position = position
id = hash.fetch(:id, DEFAULT_PACKET_ID)
super(PacketSchema.call(hash.merge(id: id)))
end
|
Instance Method Details
#to_h ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/arbetsformedlingen/models/packet.rb', line 34
def to_h
hash = super
hash[:publication] = @publication.to_h
hash[:document] = @document.to_h
hash[:position] = @position.to_h
hash
end
|