Sha256: 788beb2eeea224dd9a72c0714dc47e722e1b481284e0fff3d2c1cd86dd4b84b8

Contents?: true

Size: 614 Bytes

Versions: 28

Compression:

Stored size: 614 Bytes

Contents

module Ddr
  module Contacts
    extend ActiveSupport::Autoload

    class << self
      attr_accessor :contacts
    end

    def self.get(contact_slug)
      load_contacts unless contacts
      contacts[contact_slug]
    end

    def self.load_contacts
      self.contacts = OpenStruct.new
      contacts_file = File.join(Rails.root, 'config', 'contacts.yml')
      YAML.load_file(contacts_file).each do |key, value|
        contacts[key] = OpenStruct.new(value.merge('slug' => key))
      end
    rescue SystemCallError
      Rails.logger.warn("Unable to load Contacts file: #{contacts_file}")
    end

  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.3 lib/ddr/contacts.rb
ddr-models-3.0.0.beta.2 lib/ddr/contacts.rb
ddr-models-2.3.2 lib/ddr/contacts.rb
ddr-models-3.0.0.beta.1 lib/ddr/contacts.rb
ddr-models-2.3.1 lib/ddr/contacts.rb
ddr-models-3.0.0.alpha.4 lib/ddr/contacts.rb
ddr-models-3.0.0.alpha.3 lib/ddr/contacts.rb
ddr-models-2.3.0 lib/ddr/contacts.rb
ddr-models-3.0.0.alpha.2 lib/ddr/contacts.rb
ddr-models-3.0.0.alpha.1 lib/ddr/contacts.rb
ddr-models-2.2.0 lib/ddr/contacts.rb
ddr-models-2.1.3 lib/ddr/contacts.rb
ddr-models-2.1.2 lib/ddr/contacts.rb
ddr-models-2.1.1 lib/ddr/contacts.rb
ddr-models-2.1.0 lib/ddr/contacts.rb
ddr-models-2.1.0.rc2 lib/ddr/contacts.rb
ddr-models-2.1.0.rc1 lib/ddr/contacts.rb
ddr-models-2.0.1 lib/ddr/contacts.rb
ddr-models-2.0.0 lib/ddr/contacts.rb
ddr-models-2.0.0.rc6 lib/ddr/contacts.rb