bagman 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md ADDED
@@ -0,0 +1,9 @@
1
+ # 0.0.2
2
+
3
+ - Added `uncast` field type. This field type adds accessors for the field, and that's it! No ActiveRecord value casting is done, its all left up to the JSON serialiser.
4
+ Useful for setting `Arrays` and `Hashes`. [lachie]
5
+
6
+
7
+ # 0.0.1
8
+
9
+ - Initial release [lachie]
data/lib/bagman/bag.rb CHANGED
@@ -23,10 +23,16 @@ module Bagman
23
23
  if options[:unbagged]
24
24
  # no-op
25
25
  # unbagged_field(name, type, options, &blk)
26
+
26
27
  elsif options[:encrypted]
27
28
  crypto_field(name, type, options, &blk)
29
+
30
+ elsif options[:uncast]
31
+ uncast_bag_field(name, type, options, &blk)
32
+
28
33
  else
29
34
  bag_field(name, type, options, &blk)
35
+
30
36
  end
31
37
  end
32
38
 
@@ -60,6 +66,19 @@ module Bagman
60
66
  end
61
67
 
62
68
 
69
+ def uncast_bag_field(name, type, options, &blk)
70
+ name = name.to_s
71
+
72
+ target_class.send :define_method, name do
73
+ self.bag[name]
74
+ end
75
+
76
+ target_class.send :define_method, "#{name}=" do |value|
77
+ self.bag[name] = value
78
+ end
79
+ end
80
+
81
+
63
82
  def crypto_field(name, type, options, &blk)
64
83
  name = name.to_s
65
84
  @columns << (column = SimpleColumn.new(name, :crypto, type, options))
@@ -1,3 +1,3 @@
1
1
  module Bagman
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bagman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lachie Cox
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-19 00:00:00 Z
19
+ date: 2011-07-27 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
22
  description: We built Bagman for a project. We wanted fast prototyping and development, and some level of escape from the schema on relational databases.
@@ -31,6 +31,7 @@ extra_rdoc_files: []
31
31
 
32
32
  files:
33
33
  - .gitignore
34
+ - Changelog.md
34
35
  - Gemfile
35
36
  - License
36
37
  - Rakefile