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



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

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



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

def build_classified
  classifieds.build(owner: owner)
end

#checkout_required?Boolean

Returns:

  • (Boolean)


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

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

#classifiedObject



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

def classified
  classifieds.first
end

#classified!Object

After the configure Classified step



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

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

  save!
end

#done?Boolean

Returns:

  • (Boolean)


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

def done?
  
end

#in_progress?Boolean

Returns:

  • (Boolean)


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

def in_progress?
  draft?
end

#no_checkout_required?Boolean

Returns:

  • (Boolean)


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

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



161
162
163
164
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 161

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

#to_sObject

Instance Methods



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

def to_s
  model_name.human
end