Class: Hdo::StortingImporter::Proposition

Inherits:
Object
  • Object
show all
Includes:
HasJsonSchema, Inspectable, IvarEquality
Defined in:
lib/hdo/storting_importer/proposition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Inspectable

#short_inspect_string

Methods included from IvarEquality

#==, #__ivars__, #hash

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

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/hdo/storting_importer/proposition.rb', line 8

def body
  @body
end

#delivered_byObject (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

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/hdo/storting_importer/proposition.rb', line 8

def description
  @description
end

#external_idObject (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_ofObject (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

.exampleObject



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_exampleObject



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_inspectObject



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_hashObject



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