Class: Mumuki::Classroom::Event::ProgressTransfer

Inherits:
Object
  • Object
show all
Defined in:
lib/mumuki/classroom/event/progress_transfer.rb

Defined Under Namespace

Classes: Base, Copy, Move

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ ProgressTransfer

Returns a new instance of ProgressTransfer.



4
5
6
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 4

def initialize(body)
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



2
3
4
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 2

def body
  @body
end

Instance Method Details

#destination_organizationObject



16
17
18
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 16

def destination_organization
  Organization.locate! body[:to]
end

#execute!Object



8
9
10
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 8

def execute!
  transfer_type.new(progress_item, source_organization, destination_organization).execute!
end

#progress_itemObject



20
21
22
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 20

def progress_item
  Indicator.find(body[:item_id])
end

#source_organizationObject



12
13
14
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 12

def source_organization
  Organization.locate! body[:from]
end

#transfer_typeObject



24
25
26
# File 'lib/mumuki/classroom/event/progress_transfer.rb', line 24

def transfer_type
  self.class.const_get(body[:transfer_type].camelize)
end