bagman 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +5 -0
- data/lib/bagman/document.rb +27 -0
- data/lib/bagman/version.rb +1 -1
- metadata +4 -4
data/Changelog.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.0.3
|
2
|
+
|
3
|
+
- Added `bag_field` class method to `Bagman::Document`s. This allows for adding adhoc accessors for conveniently accessing verbatim bag values. [lachie]
|
4
|
+
- Added naive bag copying from superclasses. [lachie]
|
5
|
+
|
1
6
|
# 0.0.2
|
2
7
|
|
3
8
|
- 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.
|
data/lib/bagman/document.rb
CHANGED
@@ -117,13 +117,40 @@ module Bagman
|
|
117
117
|
|
118
118
|
|
119
119
|
module ClassMethods
|
120
|
+
|
120
121
|
def bag(&blk)
|
121
122
|
if block_given?
|
123
|
+
@bagman_has_no_bag = false
|
122
124
|
@bag = Bag.new(self, &blk)
|
123
125
|
else
|
126
|
+
unless @bag
|
127
|
+
@bag = __super_bag
|
128
|
+
@bagman_has_no_bag = ! @bag
|
129
|
+
end
|
130
|
+
|
131
|
+
raise "no bag defined" if @bagman_has_no_bag
|
132
|
+
|
124
133
|
@bag
|
125
134
|
end
|
126
135
|
end
|
136
|
+
|
137
|
+
|
138
|
+
def __super_bag
|
139
|
+
superclass.bag if superclass.respond_to?(:bag)
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def bag_field(name)
|
144
|
+
class_eval <<-EOMETHOD
|
145
|
+
def #{name}=(value)
|
146
|
+
bag["#{name}"] = value
|
147
|
+
end
|
148
|
+
|
149
|
+
def #{name}
|
150
|
+
bag["#{name}"]
|
151
|
+
end
|
152
|
+
EOMETHOD
|
153
|
+
end
|
127
154
|
end
|
128
155
|
end
|
129
156
|
|
data/lib/bagman/version.rb
CHANGED
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
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-
|
19
|
+
date: 2011-08-11 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.
|