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



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

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



136
137
138
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 136

def build_classified
  classifieds.build(owner: owner)
end

#checkout_required?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 124

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

#classifiedObject



132
133
134
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 132

def classified
  classifieds.first
end

#classified!Object

After the configure Classified step



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

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

  save!
end

#done?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 120

def done?
  
end

#in_progress?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 116

def in_progress?
  draft?
end

#no_checkout_required?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 128

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



154
155
156
157
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 154

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

#to_sObject

Instance Methods



112
113
114
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 112

def to_s
  model_name.human
end