fauna 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.2.5 Anonymous class configuration
2
+
1
3
  v0.2.4 Event set query API
2
4
 
3
5
  v0.2.3 Event set API enhancements
data/Manifest CHANGED
@@ -4,6 +4,7 @@ LICENSE
4
4
  Manifest
5
5
  README.md
6
6
  Rakefile
7
+ examples/welcome.rb
7
8
  fauna.gemspec
8
9
  lib/fauna.rb
9
10
  lib/fauna/client.rb
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.4"
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-05"
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(klass, args = {}, &block)
19
- res = ResourceDDL.new(klass, args)
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
@@ -64,4 +64,7 @@ Fauna.schema do |f|
64
64
  end
65
65
 
66
66
  with Comment
67
+
68
+ # use-case: using the ruby gem to define a schema for another environment.
69
+ with :class_name => "classes/anon"
67
70
  end
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
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-05 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel