Permalink
Browse files

Version bump to 0.1.1

  • Loading branch information...
1 parent 1fc09d3 commit f5c8ebb24597026a39fde82b6b4be2b6bedfff3c @softprops committed Dec 2, 2009
Showing with 27 additions and 12 deletions.
  1. +1 −1 VERSION
  2. +3 −4 lib/yuki.rb
  3. +23 −7 test/yuki_test.rb
View
@@ -1 +1 @@
-0.1.0
+0.1.1
View
@@ -155,15 +155,14 @@ def build(hashes)
# or
# "Bar"
def resolve(cls_def)
- if cls_def.kind_of? Hash
+ if cls_def.is_a? Hash
class_key = cls_def.keys.first
clazz = resolve(cls_def[class_key][:type])
- resource = clazz.new(info[class_key]) if clazz
else
clazz = begin
- cls_def.split("::").inject(Object) { |obj, const|
+ cls_def.to_s.split("::").inject(Object) { |obj, const|
obj.const_get(const)
- } unless cls_def.strip.empty?
+ } unless cls_def.to_s.strip.empty?
rescue NameError => e
puts "given #{cls_def} got #{e.inspect}"
raise e
View
@@ -81,6 +81,28 @@ class MutableNinja
end
end
+ context "a module's type" do
+ module Moo
+ class Bar
+ include Yuki
+ end
+ end
+
+ should "be resolved given a hash with type attr" do
+ assert_equal Moo::Bar.resolve(
+ {
+ :class_id => {
+ :type => :"YukiTest::Moo::Bar"
+ }
+ }
+ ), Moo::Bar
+ end
+
+ should "be resolved given a string representation of the classes name" do
+ assert_equal Moo::Bar.resolve("YukiTest::Moo::Bar"), Moo::Bar
+ end
+ end
+
context "a model's lifecyle operations" do
should "provide callbacks" do
@@ -105,13 +127,7 @@ def after_delete; @ad = true; end
context "a model's serialized type" do
should "default to the model's class name" do
- module Foo
- class Bar
- include Yuki
- end
- end
-
- assert "YukiTest::Foo::Bar", Foo::Bar.new.to_h['type']
+ assert "YukiTest::Moo::Bar", Moo::Bar.new.to_h['type']
end
end

0 comments on commit f5c8ebb

Please sign in to comment.