class Configuration

Schema Information

Table name: configurations

id         :integer          not null, primary key
settings   :text
type       :string(255)
created_at :datetime
updated_at :datetime
university_id :integer

Public Class Methods

load_sub_configurations() click to toggle source

To load sub configurations

# File app/models/configuration.rb, line 52
def self.load_sub_configurations
  configurations = []
  descendants.each do |d|
    configurations << d.first_or_initialize
  end
  configurations
end
profile_steps_for_universities() click to toggle source

To get profile steps for universities

# File app/models/configuration.rb, line 61
def self.profile_steps_for_universities
  if User.current and User.current.type == 'Student'
    [
      'courses_studying', 'select-type'
    ]
  else
    [
      'courses_studying', 'courses-tutoring', 'my-rate'
    ]
  end
end
store_attributes(*args) click to toggle source

To get the store attributes

# File app/models/configuration.rb, line 18
def self.store_attributes(*args)
  if self.table_exists?
    options = args.pop if args.last.is_a? Hash
    store :settings, accessors: args
    unless options.blank?
      options[:boolean_fields].each do |field_name|
        define_method "#{field_name}?" do
          self.send(field_name)
        end
        self.before_validation {|configuration|
          configuration.send("#{field_name}=".to_sym, configuration.send(field_name).try(:to_bool))
          true
        }
      end
    end

    args.each do |field_name|
      self.singleton_class.send :define_method, field_name do
        first.try(field_name)
      end

      self.singleton_class.send :define_method, "#{field_name}?".to_sym do
        self.send(field_name).present?
      end
    end
  end
end
sub_configurations() click to toggle source

To get the subclass

# File app/models/configuration.rb, line 47
def self.sub_configurations
  descendants
end