Method: SPQR::ManageableClassMixins#qmf_property

Defined in:
lib/spqr/manageable.rb

#qmf_property(name, kind, options = nil) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/spqr/manageable.rb', line 176

def qmf_property(name, kind, options=nil)
  spqr_meta.declare_property(name, kind, options)
  
  # add a property accessor to instances of other
  self.class_eval do
    # XXX: should cons up a "safe_attr_accessor" method that works like this:
    attr_reader name.to_sym unless instance_methods.include? "#{name}"
    attr_writer name.to_sym unless instance_methods.include? "#{name}="
  end
  
  if options and options[:index]
    # if this is an index property, add a find-by method if one
    # does not already exist
    spqr_define_index_find(name)
  end
end