Sha256: e5c24baf1f59e9cc513eaa1e9aad0abfdc7c18482d992a283a755aa1fb58c227
Contents?: true
Size: 558 Bytes
Versions: 2
Compression:
Stored size: 558 Bytes
Contents
class EventResource < ActiveRecord::Base belongs_to :event belongs_to :user_resource, :class_name => 'User', :foreign_key => :resource_id belongs_to :task_resource, :class_name => 'Task', :foreign_key => :resource_id def user user_resource if resource_type == 'User' end def task task_resource if resource_type == 'Task' end def resource=(r) if r.is_a?(User) self.user_resource = r else self.task_resource = r end self.resource_type = r.class.to_s r end def resource user || task end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mockumentary-0.2.1 | spec/fixtures/app/models/event_resource.rb |
mockumentary-0.2.0 | spec/fixtures/app/models/event_resource.rb |