Sha256: d2398c604aff588558ad2833c4ac6fb6ebc6adc7812baa7e74169866a0a5fcd9
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
class ProviderGroup < ActiveRecord::Base include Redis::Objects mount_uploader :icon, IconUploader value :timestamp, :global => true, :marshal => true after_save do self.class.timestamp = updated_at end after_destroy do self.class.timestamp = DateTime.now end belongs_to :provider_group has_many :provider_groups, :order => :title has_many :providers has_many :terminal_profile_provider_groups, :dependent => :destroy accepts_nested_attributes_for :providers validates :title, :presence => true def self.tree(exclude=nil) result = {} inject = lambda{|result, exclude, entry, level| unless entry == exclude result["#{'--'*level}#{' ' if level > 0}#{entry.title}"] = entry.id entry.provider_groups.each do |x| inject.call(result, exclude, x, level+1) end end } ProviderGroup.where(:provider_group_id => nil).order(:title). select{|x| x.provider_group.blank?}.each do |x| inject.call(result, exclude, x, 0) end result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
smartkiosk-server-0.9.3 | app/models/provider_group.rb |
smartkiosk-server-0.9.2 | app/models/provider_group.rb |
smartkiosk-server-0.9.1 | app/models/provider_group.rb |