Class: NamingFormats::LandParcels::BuildActivityProductionNameInteractor

Inherits:
Object
  • Object
show all
Defined in:
app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(activity_production) ⇒ BuildActivityProductionNameInteractor

Returns a new instance of BuildActivityProductionNameInteractor.


12
13
14
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 12

def initialize(activity_production)
  @activity_production = activity_production
end

Instance Attribute Details

#activity_productionObject (readonly)

Returns the value of attribute activity_production


10
11
12
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 10

def activity_production
  @activity_production
end

#build_nameObject (readonly)

Returns the value of attribute build_name


10
11
12
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 10

def build_name
  @build_name
end

#errorObject (readonly)

Returns the value of attribute error


10
11
12
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 10

def error
  @error
end

Class Method Details

.call(activity_production: nil) ⇒ Object


4
5
6
7
8
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 4

def self.call(activity_production: nil)
  interactor = new(activity_production)
  interactor.run
  interactor
end

Instance Method Details

#fail?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 34

def fail?
  !@error.nil?
end

#runObject


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 16

def run
  @build_name = NamingFormats::LandParcels::BuildNamingService
                .new(cultivable_zone: @activity_production.cultivable_zone,
                     activity: @activity_production.activity,
                     campaign: @activity_production.campaign,
                     season: @activity_production.season)
                .perform(field_values: naming_format_fields_names)

  rank_number = :rank.t(number: @activity_production.rank_number)
  @build_name.concat(" #{rank_number}")
rescue StandardError => exception
  fail!(exception.message)
end

#success?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'app/interactors/naming_formats/land_parcels/build_activity_production_name_interactor.rb', line 30

def success?
  @error.nil?
end