Module: SPQR::Manageable

Defined in:
lib/spqr/manageable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other) ⇒ Object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/spqr/manageable.rb', line 227

def self.included(other)
  class << other
    include ManageableClassMixins
  end

  unless other.respond_to? :find_by_id
    def other.find_by_id(id)
      raise "#{self} must define find_by_id(id)"
    end
  end

  unless other.respond_to? :find_all
    def other.find_all
      raise "#{self} must define find_all"
    end
  end

  unless other.respond_to? :class_id
    def other.class_id
      package_list = spqr_meta.package.to_s.split(".")
      cls = spqr_meta.classname.to_s or self.name.to_s
      ((package_list.map {|pkg| pkg.capitalize} << cls).join("::")).hash & 0x7fffffff
    end
  end

  name_components = other.name.to_s.split("::")
  other.qmf_class_name name_components.pop
  other.qmf_package_name name_components.join(".").downcase
end

Instance Method Details

#logObject



223
224
225
# File 'lib/spqr/manageable.rb', line 223

def log
  self.class.log
end

#qmf_idObject



219
220
221
# File 'lib/spqr/manageable.rb', line 219

def qmf_id
  [qmf_oid, self.class.class_id]
end

#qmf_oidObject



206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/spqr/manageable.rb', line 206

def qmf_oid
  result = 0
  if self.respond_to? :spqr_object_id 
    result = spqr_object_id
  elsif self.respond_to? :row_id
    result = row_id
  else
    result = object_id
  end
  
  result & 0x7fffffff
end