Module: Informante
- Extended by:
- Informante
- Included in:
- Informante
- Defined in:
- lib/informante.rb,
lib/informante/version.rb,
lib/informante/templates.rb
Defined Under Namespace
Modules: Generators
Constant Summary collapse
- VERSION =
"0.0.1"
- NAME_TEMPLATE_CONIG =
'informante.yml'
- NAME_TEMPLATE_INITIALIZERS =
'informante.rb'
Instance Method Summary collapse
- #config(type = :hash) ⇒ Object
- #file_informante ⇒ Object
- #file_informante_to_yaml ⇒ Object
- #path_file_informante_config ⇒ Object
- #set(type = nil) ⇒ Object
- #to_array ⇒ Object
- #to_hash ⇒ Object
- #to_object ⇒ Object
- #to_string ⇒ Object
Instance Method Details
#config(type = :hash) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 ⇒ Object
49 50 51 |
# 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 ⇒ Object
53 54 55 56 57 58 59 60 61 |
# 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 ⇒ Object
45 46 47 |
# File 'lib/informante.rb', line 45 def path_file_informante_config Rails.root.join('config', Informante::NAME_TEMPLATE_CONIG) end |
#set(type = nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/informante.rb', line 8 def set(type = nil) return nil unless type config(type) end |
#to_array ⇒ Object
33 34 35 |
# File 'lib/informante.rb', line 33 def to_array to_hash.to_a end |
#to_hash ⇒ Object
29 30 31 |
# File 'lib/informante.rb', line 29 def to_hash file_informante_to_yaml.recursive_symbolize_keys! end |
#to_object ⇒ Object
41 42 43 |
# File 'lib/informante.rb', line 41 def to_object InformanteObject.new to_hash end |
#to_string ⇒ Object
37 38 39 |
# File 'lib/informante.rb', line 37 def to_string to_hash.to_s end |