Permalink
Browse files

- add has_one method

  • Loading branch information...
1 parent 5f3d639 commit 792ee32c2688930b989a6ab876f44d1f89d06430 @superjustin superjustin committed May 16, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/simple_record/attributes.rb
@@ -235,8 +235,10 @@ def has_many(*args)
#I couldn't pass the id when calling find, since the original find doesn't work that way, so I was left with this.
end
- def has_one(*args)
-
+ def has_many(association_id, options = {})
+ send(:define_method, association_id) do
+ return eval(%{Activerecordtosdb_subrecord_array.new('#{options[:class_name] ? options[:class_name] : association_id}', '#{options[:class_name] ? association_id.to_s : self.class.name}', id)}).first
+ end
end
@@ -437,4 +439,4 @@ def init_value(value)
end
end
-end
+end

0 comments on commit 792ee32

Please sign in to comment.