Sha256: 7d3bafe86d4da306bd91d58c83ac09acfaa4825a07f87e4c180b46c4bed78a8d
Contents?: true
Size: 1.32 KB
Versions: 33
Compression:
Stored size: 1.32 KB
Contents
module Rhosync class App < Model field :name, :string set :users, :string set :sources, :string attr_reader :delegate validates_presence_of :name class << self def create(fields={}) fields[:id] = fields[:name] begin require under_score(fields[:name]) rescue Exception; end super(fields) end end def can_authenticate? self.delegate && self.delegate.singleton_methods.include?("authenticate") end def authenticate(login, password, session) if self.delegate && self.delegate.authenticate(login, password, session) user = User.load(login) if User.is_exist?(login) if not user user = User.create(:login => login) users << user.id end return user end end def delegate @delegate.nil? ? Object.const_get(camelize(self.name)) : @delegate end def partition_sources(partition,user_id) names = [] sources.members.each do |source| s = Source.load(source,{:app_id => self.name, :user_id => user_id}) if s.partition == partition names << s.name end end names end def store_blob(obj,field_name,blob) self.delegate.send :store_blob, obj,field_name,blob end end end
Version data entries
33 entries across 33 versions & 1 rubygems