Class: Return

Inherits:
Object
  • Object
show all
Defined in:
app/models/return.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, items) ⇒ Return

Returns a new instance of Return.



4
5
6
7
# File 'app/models/return.rb', line 4

def initialize(order, items)
  self.order = order
  self.items = items
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



2
3
4
# File 'app/models/return.rb', line 2

def items
  @items
end

#orderObject

Returns the value of attribute order.



2
3
4
# File 'app/models/return.rb', line 2

def order
  @order
end

Instance Method Details

#submitObject



9
10
11
12
13
# File 'app/models/return.rb', line 9

def submit
  @success = items.map(&:return!).reduce(&:&)
rescue Transitions::InvalidTransition
  @success = false
end

#successful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/models/return.rb', line 15

def successful?
  @success || false
end