Sha256: 3822f0789f319e12299f15cf35044b1195ccc3183eec9fbe842ea1bbadaa26a3

Contents?: true

Size: 867 Bytes

Versions: 27

Compression:

Stored size: 867 Bytes

Contents

module Workarea
  class Segment
    module LifeCycle
      extend ActiveSupport::Concern

      included do
        field :_id, type: String, default: -> { self.class.instance_id }
        cattr_accessor :default_rules
      end

      class_methods do
        def model_name
          Segment.model_name
        end

        def instance
          first || create!(name: instance_name, rules: default_rules)
        end

        def instance_id
          name.demodulize.underscore.to_sym
        end

        def instance_name
          name.demodulize.underscore.titleize
        end
      end

      def self.create!
        [
          FirstTimeVisitor,
          ReturningVisitor,
          FirstTimeCustomer,
          ReturningCustomer,
          LoyalCustomer
        ].each(&:instance)
      end

      def destroy
        false
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
workarea-core-3.5.6 app/models/workarea/segment/life_cycle.rb
workarea-core-3.5.5 app/models/workarea/segment/life_cycle.rb
workarea-core-3.5.4 app/models/workarea/segment/life_cycle.rb
workarea-core-3.5.3 app/models/workarea/segment/life_cycle.rb
workarea-core-3.5.2 app/models/workarea/segment/life_cycle.rb
workarea-core-3.5.1 app/models/workarea/segment/life_cycle.rb
workarea-core-3.5.0 app/models/workarea/segment/life_cycle.rb