class Octo::Enterprise

Constants

TTL

Set ttl of 120 minutes for the caches

Public Instance Methods

_setup() click to toggle source

Setup the new enterprise

# File lib/octocore-mongo/models/enterprise.rb, line 21
def _setup
  setup_notification_categories
  setup_intelligent_segments
end
fakedata?() click to toggle source

Method to check if it is okay to create fakedata for this

client

@return [Boolean]

# File lib/octocore-mongo/models/enterprise.rb, line 29
def fakedata?
  self.name.start_with?('Octo')
end

Private Instance Methods

setup_intelligent_segments() click to toggle source

Setup the intelligent segments for the enterprise

# File lib/octocore-mongo/models/enterprise.rb, line 53
def setup_intelligent_segments
  segments = Octo.get_config(:intelligent_segments)
  if segments
    segments.each do |seg|
      args = {
        enterprise_id: self._id,
        name: seg[:name],
        type: seg[:type].constantize,
        dimensions: seg[:dimensions].collect(&:constantize),
        operators: seg[:operators].collect(&:constantize),
        values: seg[:values].collect(&:constantize),
        active: true,
        intelligence: true,
      }
      Octo::Segment.new(args).save!
    end
    Octo.logger.info "Created segents for Enterprise: #{ self.name }"
  end
end
setup_notification_categories() click to toggle source

Setup the notification categories for the enterprise

# File lib/octocore-mongo/models/enterprise.rb, line 36
def setup_notification_categories
  templates = Octo.get_config(:push_templates)
  if templates
    templates.each do |t|
      args = {
        enterprise_id: self._id,
        category_type: t[:name],
        template_text: t[:text],
        active: true
      }
      Octo::Template.new(args).save!
    end
    Octo.logger.info("Created templates for Enterprise: #{ self.name }")
  end
end