Module: App47AppConfigurable

Extended by:
ActiveSupport::Concern
Included in:
InternalApp, ProductApp
Defined in:
lib/models/concerns/app47_app_configurable.rb

Overview

An app that can have a configuration

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Add methods to class



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/models/concerns/app47_app_configurable.rb', line 11

def self.included(base)
  base.class_eval do
    #
    # Relationships
    #
    has_many :configuration_groups, dependent: :destroy, inverse_of: :app do
      #
      # Return configuration groups that match the agent
      #
      def match_agent(agent)
        where(active: true).collect do |group|
          next unless group.match_agent?(agent)

          { version: group.version, id: group.id.to_s }
        end.compact
      end
    end
    #
    # Fields
    #
    field :configurable, type: Mongoid::Boolean, default: true
  end
end