ztk 1.6.30 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ztk/dsl/base.rb +14 -5
- data/lib/ztk/dsl/core/actions/find.rb +5 -1
- data/lib/ztk/dsl/core/attributes.rb +6 -0
- data/lib/ztk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDlkMjkwMjJjNmFmN2I1YzBhMmUxOWUyYTU2NmMzYTM5OGQxOGE0Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGQ1ZTAxZjExYzkwOTA4MjYzZGQ2YTU5MjNmMTgxYmY3NTQ3MmQ1ZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzhjMDg1MTQ1NWRjNmI2YWY5Y2U0YjQxOGI3ZjE5OGNiNTgwMjkxY2UxODdh
|
10
|
+
YWEwZDIwYzJmNWQxNTdhY2U5NzMyZmZhN2IzNTQ1MWMwMjZhNWYwMWVlODg1
|
11
|
+
ZjBmZjJmZDVmYjJlNTBiMDFjYzFlNTU3NTJmOTUxMTQ3MTZjMWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGRmMzE2NjdjYWNlMjNmY2VmYzc3MTJkNDJmN2NmZmZmNTAwNjQ1MThkZDZl
|
14
|
+
MzE0MWM0OTM1YWRhMzNiMzI5OWQ1YjU1YTQxYjQ0OWY2Zjk5Y2ZmNjE0Y2Fi
|
15
|
+
OGYwZWU2M2UzNzZlOWMwZDI5NTk2NjQwNDE3ZGFjYWViYzUyOWE=
|
data/lib/ztk/dsl/base.rb
CHANGED
@@ -154,12 +154,21 @@ module ZTK::DSL
|
|
154
154
|
self.id = (id || self.class.next_id)
|
155
155
|
self.class.dataset << self
|
156
156
|
|
157
|
-
|
157
|
+
do_block(&block)
|
158
|
+
end
|
159
|
+
|
160
|
+
def do_block(&block)
|
161
|
+
if block_given?
|
162
|
+
if (block.arity < 1)
|
163
|
+
instance_eval(&block)
|
164
|
+
else
|
165
|
+
block.call(self)
|
166
|
+
end
|
167
|
+
end
|
158
168
|
|
159
|
-
|
160
|
-
|
169
|
+
if (self.class.dataset.count{ |data| (data.id == self.id) } > 1)
|
170
|
+
raise StandardError, "Primary key '#{self.id}' already exists!"
|
161
171
|
end
|
162
|
-
raise StandardError, "Primary key '#{self.id}' already exists!" if (primary_key_count > 1)
|
163
172
|
end
|
164
173
|
|
165
174
|
# Instance Inspect
|
@@ -188,7 +197,7 @@ module ZTK::DSL
|
|
188
197
|
def inspect
|
189
198
|
details = Array.new
|
190
199
|
details << "count=#{self.all.count}" if self.all.count > 0
|
191
|
-
"#<#{self.
|
200
|
+
"#<#{self.to_s} #{details.join(', ')}>"
|
192
201
|
end
|
193
202
|
|
194
203
|
end
|
@@ -35,7 +35,13 @@ module ZTK::DSL::Core
|
|
35
35
|
|
36
36
|
send(:define_method, "#{key}=") do |value|
|
37
37
|
attributes[key] = value
|
38
|
+
value
|
38
39
|
end
|
40
|
+
|
41
|
+
self.class.send(:define_method, "find_by_#{key}") do |value|
|
42
|
+
all.select{ |object| (object.send(key) == value) }
|
43
|
+
end
|
44
|
+
|
39
45
|
end
|
40
46
|
|
41
47
|
end
|
data/lib/ztk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Patten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|