Module: EffectiveClassifiedsClassifiedWizard

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/effective_classifieds_classified_wizard.rb

Overview

EffectiveClassifiedsClassifiedWizard

Mark your owner model with effective_classifieds_classified_wizard to get all the includes

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#assign_pricingObject



150
151
152
153
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 150

def assign_pricing
  raise('to be implemented by including class')
  # classified.assign_attributes(price: price, qb_item_name: qb_item_name, tax_exempt: tax_exempt)
end

#build_classifiedObject



146
147
148
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 146

def build_classified
  classifieds.build(owner: owner)
end

#checkout_required?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 134

def checkout_required?
  required_steps.include?(:billing) && required_steps.include?(:checkout)
end

#classifiedObject



142
143
144
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 142

def classified
  classifieds.first
end

#classified!Object

After the configure Classified step



156
157
158
159
160
161
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 156

def classified!
  assign_pricing() if classified.present?
  raise('expected classified to have a price') if classified.price.blank?

  save!
end

#done?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 130

def done?
  
end

#in_progress?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 126

def in_progress?
  draft?
end

#no_checkout_required?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 138

def no_checkout_required?
  required_steps.exclude?(:billing) && required_steps.exclude?(:checkout)
end

#summary!Object

This is the review/summary step. Last one if we’re not doing checkout



164
165
166
167
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 164

def summary!
  return submit! if no_checkout_required?
  save!
end

#to_sObject

Instance Methods



122
123
124
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 122

def to_s
  model_name.human
end