devise_simply_stored 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ #require 'orm_adapter/adapters/simply_stored'
1
2
  module Devise
2
3
  module Orm
3
4
  module SimplyStored
@@ -41,7 +42,7 @@ module Devise
41
42
  yield
42
43
  # Apply schema to model
43
44
  devise_modules.each do |m|
44
- send(m)
45
+ send(m) if respond_to?(m)
45
46
  end
46
47
  Devise.authentication_keys.each do |key|
47
48
  property key
@@ -1,6 +1,11 @@
1
1
 
2
2
  require "devise_simply_stored/version"
3
- require 'devise/orm/simply_stored'
3
+ #begin
4
+ require 'devise/orm/simply_stored'
5
+ #rescue
6
+ # require 'orm_adapter/adapters/simply_stored'
7
+ #end
8
+
9
+ # Initialize the module
4
10
  module DeviseSimplyStored
5
- # Your code goes here...
6
11
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseSimplyStored
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,66 @@
1
+ require 'simply_stored'
2
+
3
+ module SimplyStored
4
+ module Couch
5
+ module ClassMethods
6
+ include OrmAdapter::ToAdapter
7
+ end
8
+
9
+ class OrmAdapter < ::OrmAdapter::Base
10
+ # Do not consider these to be part of the class list
11
+ def self.except_classes
12
+ @@except_classes ||= []
13
+ end
14
+
15
+ # Gets a list of the available models for this adapter
16
+ def self.model_classes
17
+ ObjectSpace.each_object(Class).to_a.select {|klass| klass.ancestors.include? SimplyStored::Couch}
18
+ end
19
+
20
+ # get a list of column names for a given class
21
+ def column_names
22
+ klass.fields.keys
23
+ end
24
+
25
+ # @see OrmAdapter::Base#get!
26
+ def get!(id)
27
+ klass.find(wrap_key(id))
28
+ end
29
+
30
+ # @see OrmAdapter::Base#get
31
+ def get(id)
32
+ klass.where(:_id => wrap_key(id)).first
33
+ end
34
+
35
+ # @see OrmAdapter::Base#find_first
36
+ def find_first(options)
37
+ conditions, order = extract_conditions_and_order!(options)
38
+ klass.limit(1).where(conditions_to_fields(conditions)).order_by(order).first
39
+ end
40
+
41
+ # @see OrmAdapter::Base#find_all
42
+ def find_all(options)
43
+ conditions, order = extract_conditions_and_order!(options)
44
+ klass.where(conditions_to_fields(conditions)).order_by(order)
45
+ end
46
+
47
+ # @see OrmAdapter::Base#create!
48
+ def create!(attributes)
49
+ klass.create!(attributes)
50
+ end
51
+
52
+ protected
53
+
54
+ # converts and documents to ids
55
+ def conditions_to_fields(conditions)
56
+ conditions.inject({}) do |fields, (key, value)|
57
+ if value.is_a?(SimplyStored::Couch) && klass.fields.keys.include?("#{key}_id")
58
+ fields.merge("#{key}_id" => value.id)
59
+ else
60
+ fields.merge(key => value)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_simply_stored
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000Z
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
16
- requirement: &70302889459520 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70302889459520
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: This gem enables devise for simply_stored
26
31
  email:
27
32
  - bterkuile@gmail.com
@@ -38,6 +43,7 @@ files:
38
43
  - lib/devise/orm/simply_stored.rb
39
44
  - lib/devise_simply_stored.rb
40
45
  - lib/devise_simply_stored/version.rb
46
+ - lib/orm_adapter/adapters/simply_stored.rb
41
47
  - spec/models/user_spec.rb
42
48
  - spec/spec_helper.rb
43
49
  - spec/support/user_model.rb
@@ -61,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
67
  version: '0'
62
68
  requirements: []
63
69
  rubyforge_project: devise_simply_stored
64
- rubygems_version: 1.8.15
70
+ rubygems_version: 1.8.24
65
71
  signing_key:
66
72
  specification_version: 3
67
73
  summary: This gem enables devise for simply_stored