module Informante

Constants

NAME_TEMPLATE_CONIG
NAME_TEMPLATE_INITIALIZERS
VERSION

Public Instance Methods

config(type = :hash) click to toggle source
# File lib/informante.rb, line 14
def config(type = :hash)
  case type
    when :hash
      to_hash
    when :object
      to_object
    when :array
      to_array
    when :string
      to_string
    else
      raise "type `:#{type}` invalid for informante"
  end
end
file_informante() click to toggle source
# File lib/informante.rb, line 49
def file_informante
  File.exist?(path_file_informante_config) ? File.read(path_file_informante_config) : nil
end
file_informante_to_yaml() click to toggle source
# File lib/informante.rb, line 53
def file_informante_to_yaml
  if self.file_informante
    begin
      YAML.load(file_informante)
    rescue => e
      raise "problem sintaxe file #{Informante::NAME_TEMPLATE_CONIG} #{e.to_s}"
    end
  end
end
path_file_informante_config() click to toggle source
# File lib/informante.rb, line 45
def path_file_informante_config
  Rails.root.join('config', Informante::NAME_TEMPLATE_CONIG)
end
set(type = nil) click to toggle source
# File lib/informante.rb, line 8
def set(type = nil)
  return nil unless type

  config(type)
end
to_array() click to toggle source
# File lib/informante.rb, line 33
def to_array
  to_hash.to_a
end
to_hash() click to toggle source
# File lib/informante.rb, line 29
def to_hash
  file_informante_to_yaml.recursive_symbolize_keys!
end
to_object() click to toggle source
# File lib/informante.rb, line 41
def to_object
  InformanteObject.new to_hash
end
to_string() click to toggle source
# File lib/informante.rb, line 37
def to_string
  to_hash.to_s
end