serialized_attributes 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -31,6 +31,10 @@ module SerializedAttributes
31
31
  attribute(name, type, opts.merge({:attr_accessible => true}))
32
32
  end
33
33
 
34
+ def serialized_attribute_names
35
+ serialized_attributes_definition.keys
36
+ end
37
+
34
38
  def attribute(name, type, opts = {})
35
39
  name = name.to_s
36
40
  type = SerializedAttributes.type_to_sqltype(type)
@@ -48,7 +52,11 @@ module SerializedAttributes
48
52
  pack_serialized_attributes!
49
53
  super
50
54
  end
51
-
55
+
56
+ def serialized_attribute_names
57
+ self.class.serialized_attribute_names
58
+ end
59
+
52
60
  def unpack_serialized_attributes!
53
61
  if @attributes.has_key?(serialized_attributes_column.to_s) && attributes = (self[serialized_attributes_column] || {})
54
62
  serialized_attributes_definition.each do |key, column|
@@ -127,4 +127,14 @@ class SimpleTest < Test::Unit::TestCase
127
127
  sprocket = Sprocket.create(:name => "Spacely's Space Sprocket", :size => 99)
128
128
  assert sprocket.size == 99
129
129
  end
130
+
131
+ # => test that the names of the serialized attributes are correctly returned by a class
132
+ def test_serizalied_attribute_names_are_returned_by_the_class
133
+ assert Sprocket.serialized_attribute_names.sort == ['in_motion', 'size'].sort
134
+ end
135
+
136
+ # => test that the names of the serialized attributes are correctly returned by the instance
137
+ def test_serizalied_attribute_names_are_returned_by_an_instance
138
+ assert Sprocket.new.serialized_attribute_names.sort == ['in_motion', 'size'].sort
139
+ end
130
140
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialized_attributes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Emma Persky