Skip to content

Instantly share code, notes, and snippets.

@theotherzach
Last active April 24, 2018 19:34
Show Gist options
  • Save theotherzach/7bf1b1c43ff6636391a08585b4f7b3ea to your computer and use it in GitHub Desktop.
Save theotherzach/7bf1b1c43ff6636391a08585b4f7b3ea to your computer and use it in GitHub Desktop.
Frontend Flow Control
class FrontendFlow < ActiveRecord
# property_id: Integer
# step: BigDecimal
# name: String
end
class FrontendFlows
class NO_FLOW_FOUND
def self.for(flow_name)
self.send(flow_name)
rescue NoMethodError => e
NO_FLOW_FOUND
end
private
def self.ho3_fl_2018a
[
Steps::ROOT,
# Note: Not all steps will be hit.
# Controllers can be responsible for optional steps or we can add optional lambdas to paths.
Steps::PROPERTIES_ADDITIONAL_INFO,
Steps::PRICES,
Steps::NEW_USER,
Steps::EDIT_COVERAGES,
Steps::NEW_INSUREDS,
#....
]
end
def self.ho3_tx_2018a
[
Steps::ROOT,
Steps::PROPERTIES_ADDITIONAL_INFO,
Steps::NEW_USER,
Steps::NEW_INSUREDS,
#....
]
end
class Steps
# Steps
ROOT = {
name: :root,
path: "root_path(start_over: true)",
cta: I18n.t("step.root.cta") # The CTA TO the step. "Start over" in this case.
}
PROPERTIES_ADDITIONAL_INFO = {
name: :additional_info,
path: "edit_additional_info_properties",
cta: I18n.t("step.properties_additional_info.cta")
}
PRICES = {
name: :prices,
path: :"prices_path",
cta: I18n.t("step.prices.cta")
}
NEW_USER = {
name: :new_user,
path: "new_user_path",
cta: I18n.t("step.new_user.cta")
}
EDIT_COVERAGES = {
name: :edit_coverages,
path: "edit_coverages_path",
cta: I18n.t("step.edit_coverages.cta")
}
NEW_INSUREDS = {
name: :new_insureds,
path: "new_insureds_path",
cta: I18n.t("step.new_insureds.cta")
}
#...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment