Class: PartnerService::Inventories::BlockService

Inherits:
Object
  • Object
show all
Defined in:
app/services/partner_service/inventories/block_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, restaurant_ids) ⇒ BlockService

Returns a new instance of BlockService.



5
6
7
8
9
10
# File 'app/services/partner_service/inventories/block_service.rb', line 5

def initialize(params, restaurant_ids)
  @params = params
  @restaurant_ids = restaurant_ids
  @errors = []
  @success = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'app/services/partner_service/inventories/block_service.rb', line 3

def errors
  @errors
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'app/services/partner_service/inventories/block_service.rb', line 3

def params
  @params
end

#restaurant_idsObject (readonly)

Returns the value of attribute restaurant_ids.



3
4
5
# File 'app/services/partner_service/inventories/block_service.rb', line 3

def restaurant_ids
  @restaurant_ids
end

#successObject (readonly)

Returns the value of attribute success.



3
4
5
# File 'app/services/partner_service/inventories/block_service.rb', line 3

def success
  @success
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
# File 'app/services/partner_service/inventories/block_service.rb', line 12

def call
  validate_params!
  return self unless errors.empty?

  process_restaurants
  self
end

#messageObject



20
21
22
23
24
25
26
# File 'app/services/partner_service/inventories/block_service.rb', line 20

def message
  if success?
    success.uniq.to_sentence
  else
    errors.uniq.to_sentence
  end
end

#success?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/services/partner_service/inventories/block_service.rb', line 28

def success?
  errors.blank?
end