Class: Arbetsformedlingen::Publication
- Defined in:
- lib/arbetsformedlingen/models/publication.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#initialize(hash) ⇒ Publication
constructor
A new instance of Publication.
Methods inherited from Model
#errors, from_schema, #to_h, #valid?
Constructor Details
#initialize(hash) ⇒ Publication
Returns a new instance of Publication.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/arbetsformedlingen/models/publication.rb', line 20 def initialize(hash) data = hash.dup publish_date = data[:publish_at] || Time.now.utc data[:publish_at] = publish_date.strftime('%Y-%m-%d') data[:unpublish_at] = data[:unpublish_at]&.strftime('%Y-%m-%d') # TODO: Validate that unpublish_at - publish_at is not greater that 180 days super(PublicationSchema.call(data)) end |