65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/noah/models/configurations.rb', line 65
def self.all(options = {}, short=false)
short_keys = [:format, :created_at, :updated_at]
config_hash = Hash.new
options.empty? ? configs=Configuration.all.sort : configs=Configuration.find(options).sort
if short == false
configs.each {|x| config_hash["#{x.name}"] = x.to_hash.reject {|k,v| k == :name} }
else
configs.each do |x|
items = x.to_hash.select {|k,v| k if short_keys.include?(k)}
if items.is_a?(Array)
items_hash = {}
items.each {|item| items_hash.merge!(Hash[*item])}
else
items_hash = items
end
config_hash["#{x.name}"] = items_hash
end
end
config_hash
end
|