fauna 0.2.4 → 0.2.5
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 +2 -0
- data/Manifest +1 -0
- data/fauna.gemspec +2 -2
- data/lib/fauna/ddl.rb +18 -3
- data/test/fixtures.rb +3 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
data/fauna.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "fauna"
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Fauna, Inc."]
|
9
|
-
s.date = "2013-03-
|
9
|
+
s.date = "2013-03-11"
|
10
10
|
s.description = "Official Ruby client for the Fauna API."
|
11
11
|
s.email = ""
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "lib/fauna.rb", "lib/fauna/client.rb", "lib/fauna/connection.rb", "lib/fauna/ddl.rb", "lib/fauna/event_set.rb", "lib/fauna/model.rb", "lib/fauna/model/class.rb", "lib/fauna/model/user.rb", "lib/fauna/publisher.rb", "lib/fauna/rails.rb", "lib/fauna/resource.rb"]
|
data/lib/fauna/ddl.rb
CHANGED
@@ -15,8 +15,10 @@ module Fauna
|
|
15
15
|
|
16
16
|
# resources
|
17
17
|
|
18
|
-
def with(
|
19
|
-
|
18
|
+
def with(*args, &block)
|
19
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
20
|
+
klass = args.first
|
21
|
+
res = ResourceDDL.new(klass, options)
|
20
22
|
res.instance_eval(&block) if block_given?
|
21
23
|
@ddls << res
|
22
24
|
nil
|
@@ -24,8 +26,12 @@ module Fauna
|
|
24
26
|
|
25
27
|
class ResourceDDL
|
26
28
|
def initialize(klass, args = {})
|
29
|
+
unless klass || args[:class_name]
|
30
|
+
raise ArgumentError, "Must either provide a class or specify :class_name."
|
31
|
+
end
|
32
|
+
|
27
33
|
@event_sets = []
|
28
|
-
@class = klass
|
34
|
+
@class = klass || derived_class(args[:class_name])
|
29
35
|
@fauna_class = args[:class_name] || derived_fauna_class(@class)
|
30
36
|
|
31
37
|
unless @class <= max_super(@fauna_class)
|
@@ -73,6 +79,15 @@ module Fauna
|
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
82
|
+
def derived_class(name)
|
83
|
+
s = max_super(name)
|
84
|
+
case s
|
85
|
+
when Fauna::Class then Class.new(Fauna::Class)
|
86
|
+
when Fauna::Resource then Class.new(Fauna::Resource)
|
87
|
+
else s
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
76
91
|
def derived_fauna_class(klass)
|
77
92
|
if klass < Fauna::User
|
78
93
|
"users"
|
data/test/fixtures.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fauna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|