fossil 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fossil.gemspec +2 -2
- data/lib/sequel/model_patch.rb +28 -18
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/fossil.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fossil}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Patrick Lardin, Daniel Sudol"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-05}
|
13
13
|
s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
|
14
14
|
s.email = %q{plardin@xojet.com}
|
15
15
|
s.files = [
|
data/lib/sequel/model_patch.rb
CHANGED
@@ -5,28 +5,38 @@ class Sequel::Model
|
|
5
5
|
self.use_transactions=false
|
6
6
|
plugin :validation_helpers
|
7
7
|
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# delegated to passenger
|
8
|
+
# Passing in an array of attribute / method names, fills a hash with values from
|
9
|
+
# the model. Can pass in attributes with __ like :passenger__name and the 'name'
|
10
|
+
# value will be delegated to 'passenger' with the delegator being created on the fly.
|
11
11
|
def fill_hash(attributes)
|
12
12
|
attributes.inject({}) do |hash, attribute|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
attribute_name = attribute.to_s.gsub('__','_').to_sym
|
14
|
+
generate_delegator(attribute) unless respond_to? attribute_name
|
15
|
+
hash[attribute_name] = send(attribute_name) if respond_to? attribute_name
|
16
|
+
hash
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(method, *args, &block)
|
21
|
+
if method.to_s.split(/__/).size > 1
|
22
|
+
generate_delegator(method)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_delegator(method)
|
29
|
+
arr = method.to_s.split(/__/)
|
30
|
+
# check to see if method_name ( delegator ) exists first to ensure its not created again
|
31
|
+
unless respond_to? arr.join('_')
|
32
|
+
# create delegator on the fly
|
33
|
+
method_call = arr.shift
|
34
|
+
arr.each do |next_call|
|
35
|
+
unless respond_to?(method_call + "_" + next_call)
|
36
|
+
self.class.delegate next_call.to_sym, :to => method_call.to_sym, :prefix => true, :allow_nil => true
|
26
37
|
end
|
38
|
+
method_call = method_call + "_" + next_call
|
27
39
|
end
|
28
|
-
hash[attribute] = send(attribute) if respond_to? attribute
|
29
|
-
hash
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fossil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Lardin, Daniel Sudol
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-05 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|