lib/active_triples/property_builder.rb in active-triples-0.5.0 vs lib/active_triples/property_builder.rb in active-triples-0.6.0

- old
+ new

@@ -15,24 +15,33 @@ end def self.build(model, name, options, &block) builder = create_builder name, options, &block reflection = builder.build(&block) - define_accessors model, reflection + define_accessors model, reflection, options reflection end - def self.define_accessors(model, reflection) + def self.define_accessors(model, reflection, options={}) mixin = model.generated_property_methods name = reflection.term define_readers(mixin, name) + define_id_reader(model, name) unless options[:cast] == false define_writers(mixin, name) end def self.define_readers(mixin, name) mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{name}(*args) get_values(:#{name}) + end + CODE + end + + def self.define_id_reader(mixin, name) + mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 + def #{name}_ids(*args) + get_values(:#{name}, :cast => false) end CODE end def self.define_writers(mixin, name)