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



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

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



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

def build_classified
  classifieds.build(owner: owner)
end

#checkout_required?Boolean

Returns:

  • (Boolean)


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

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

#classifiedObject



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

def classified
  classifieds.first
end

#classified!Object

After the configure Classified step



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

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

  save!
end

#done?Boolean

Returns:

  • (Boolean)


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

def done?
  
end

#in_progress?Boolean

Returns:

  • (Boolean)


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

def in_progress?
  draft?
end

#no_checkout_required?Boolean

Returns:

  • (Boolean)


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

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



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

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

#to_sObject

Instance Methods



109
110
111
# File 'app/models/concerns/effective_classifieds_classified_wizard.rb', line 109

def to_s
  model_name.human
end