Class: Provider

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/provider.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_hash(column, entries = false, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'app/models/provider.rb', line 34

def self.to_hash(column, entries=false, options={})
  scope = Provider.select([:id, column])
  scope = scope.where(column => entries) if entries
  scope = scope.map{|x| [x.id, x.send(column)]} if options[:invert].blank?
  scope = scope.map{|x| [x.send(column), x.id]} if options[:invert]

  Hash[*scope.flatten]
end

Instance Method Details

#as_jsonObject



23
24
25
26
27
28
29
30
31
32
# File 'app/models/provider.rb', line 23

def as_json
  {
    :id => id,
    :group => group_id,
    :keyword => keyword,
    :title => title,
    :icon => icon.url,
    :fields => fields
  }
end