Sha256: 867644003e0f17372e36cf6e21636bad285d9c742d179644bd4bf3b0dc5beb07

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require "activeadmin-settings/version"

module ActiveadminSettings
  require 'activeadmin-settings/engine'
  require 'activeadmin-settings/helper'

  IMAGE_TYPES = [ 'image/jpeg',
                  'image/png',
                  'image/gif',
                  'image/jpg',
                  'image/pjpeg',
                  'image/tiff',
                  'image/x-png' ]

  mattr_accessor :image_file_types
  @@image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]


  # Load configuration from config/activeadmin_settings.yml
  def self.load_config
    config_file = ::Rails.root.join("config/activeadmin_settings.yml")
    @load_config = {}

    if File.exists?(config_file)
      data = YAML::load(ERB.new(IO.read(config_file)).result)
      @load_config = data if data
    end
    @load_config
  end

  def self.all_settings
    @all_settings = {}
    load_config.each do |key, settings|
      @all_settings.merge!(settings)
    end
    @all_settings
  end

  def self.groups
    @groups = []
    load_config.each do |key, settings|
      @groups << {:name     => key,
                  :slug     => key.downcase.gsub(" ", "_"),
                  :default_settings => settings,
                  :settings => [] }
    end
    @groups
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin-settings-0.3.0 lib/activeadmin-settings.rb
activeadmin-settings-0.2.9 lib/activeadmin-settings.rb