Class: Hdo::StortingImporter::Proposition
- Inherits:
-
Object
- Object
- Hdo::StortingImporter::Proposition
- Includes:
- HasJsonSchema, Inspectable, IvarEquality
- Defined in:
- lib/hdo/storting_importer/proposition.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#delivered_by ⇒ Object
readonly
Returns the value of attribute delivered_by.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#on_behalf_of ⇒ Object
readonly
Returns the value of attribute on_behalf_of.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(external_id, description, on_behalf_of, body, delivered_by) ⇒ Proposition
constructor
A new instance of Proposition.
- #short_inspect ⇒ Object
- #to_hash ⇒ Object
Methods included from Inspectable
Methods included from IvarEquality
Methods included from HasJsonSchema
#as_json, included, schemas, #to_json, #valid?, #validate!
Constructor Details
#initialize(external_id, description, on_behalf_of, body, delivered_by) ⇒ Proposition
Returns a new instance of Proposition.
32 33 34 35 36 37 38 |
# File 'lib/hdo/storting_importer/proposition.rb', line 32 def initialize(external_id, description, on_behalf_of, body, delivered_by) @external_id = external_id @description = description @on_behalf_of = on_behalf_of @body = body @delivered_by = delivered_by end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/hdo/storting_importer/proposition.rb', line 8 def body @body end |
#delivered_by ⇒ Object (readonly)
Returns the value of attribute delivered_by.
8 9 10 |
# File 'lib/hdo/storting_importer/proposition.rb', line 8 def delivered_by @delivered_by end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/hdo/storting_importer/proposition.rb', line 8 def description @description end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
8 9 10 |
# File 'lib/hdo/storting_importer/proposition.rb', line 8 def external_id @external_id end |
#on_behalf_of ⇒ Object (readonly)
Returns the value of attribute on_behalf_of.
8 9 10 |
# File 'lib/hdo/storting_importer/proposition.rb', line 8 def on_behalf_of @on_behalf_of end |
Class Method Details
.example ⇒ Object
12 13 14 |
# File 'lib/hdo/storting_importer/proposition.rb', line 12 def self.example new('1234', 'description', 'on behalf of', 'body', Representative.example) end |
.from_hash(hash) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hdo/storting_importer/proposition.rb', line 20 def self.from_hash(hash) arr = [ hash['externalId'], hash['description'], hash['onBehalfOf'], hash['body'], Representative.from_hash(hash['deliveredBy'] || {}) ] new(*arr) end |
.json_example ⇒ Object
16 17 18 |
# File 'lib/hdo/storting_importer/proposition.rb', line 16 def self.json_example Util.json_pretty example end |
Instance Method Details
#short_inspect ⇒ Object
40 41 42 |
# File 'lib/hdo/storting_importer/proposition.rb', line 40 def short_inspect short_inspect_string :include => [:external_id, :description, :on_behalf_of] end |
#to_hash ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/hdo/storting_importer/proposition.rb', line 44 def to_hash h = { 'kind' => self.class.kind, 'externalId' => @external_id, 'description' => @description, 'onBehalfOf' => @on_behalf_of, 'body' => @body } h['deliveredBy'] = @delivered_by.to_hash if @delivered_by h end |