couchrest_model_config 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.1.2
2
+ -- CouchRest inheritable attribute override gone. simpler method for fixing rails reloading problem.
3
+
1
4
  v0.1.1
2
5
  -- overrode the CouchRest inheritable attributes code to only create the inheritable attributes
3
6
  if they don't already exist. Should hopefully solve a problem that crops up in development mode in
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -1,19 +1,21 @@
1
1
  module CouchRest
2
2
  module Model
3
3
  class Base
4
- class << self
5
- def database
4
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
5
+ def self.database
6
6
  CouchRest::Model::Config.for(self).current_database
7
7
  end
8
-
8
+
9
+ def database
10
+ CouchRest::Model::Config.for(self.class).current_database
11
+ end
12
+ EOS
13
+
14
+ class << self
9
15
  def use_database(*args)
10
16
  raise "We're sorry, but the `use_database` method is not supported with couchrest_model_config."
11
17
  end
12
18
  end
13
-
14
- def database
15
- CouchRest::Model::Config.for(self.class).current_database
16
- end
17
19
  end
18
20
  end
19
21
  end
@@ -1,5 +1,4 @@
1
1
  require 'couchrest_model'
2
- require 'couchrest_model_config/couchrest_model_inheritable_attributes'
3
2
  require 'couchrest_model_config/config'
4
3
  require 'couchrest_model_config/model'
5
4
  require 'couchrest_model_config/server'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchrest_model_config
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Parker
@@ -96,7 +96,6 @@ files:
96
96
  - lib/couchrest_model_config.rb
97
97
  - lib/couchrest_model_config/config.rb
98
98
  - lib/couchrest_model_config/couchrest_model_base.rb
99
- - lib/couchrest_model_config/couchrest_model_inheritable_attributes.rb
100
99
  - lib/couchrest_model_config/model.rb
101
100
  - lib/couchrest_model_config/server.rb
102
101
  - readme.markdown
@@ -1,115 +0,0 @@
1
- # Copyright (c) 2006-2009 David Heinemeier Hansson
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
- #
22
- # Extracted From
23
- # http://github.com/rails/rails/commit/971e2438d98326c994ec6d3ef8e37b7e868ed6e2
24
-
25
- module CouchRest
26
- module InheritableAttributes
27
-
28
- # Defines class-level inheritable attribute reader. Attributes are available to subclasses,
29
- # each subclass has a copy of parent's attribute.
30
- #
31
- # @param *syms<Array[#to_s]> Array of attributes to define inheritable reader for.
32
- # @return <Array[#to_s]> Array of attributes converted into inheritable_readers.
33
- #
34
- # @api public
35
- #
36
- # @todo Do we want to block instance_reader via :instance_reader => false
37
- # @todo It would be preferable that we do something with a Hash passed in
38
- # (error out or do the same as other methods above) instead of silently
39
- # moving on). In particular, this makes the return value of this function
40
- # less useful.
41
- def couchrest_inheritable_reader(*ivars)
42
- instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)
43
-
44
- ivars.each do |ivar|
45
- unless self.respond_to?(ivar.to_sym)
46
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
47
- def self.#{ivar}
48
- return @#{ivar} if self.object_id == #{self.object_id} || defined?(@#{ivar})
49
- ivar = superclass.#{ivar}
50
- return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}")
51
- @#{ivar} = ivar && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
52
- end
53
- RUBY
54
- end
55
-
56
- if instance_reader == true && !self.method_defined?(ivar.to_sym)
57
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
58
- def #{ivar}
59
- self.class.#{ivar}
60
- end
61
- RUBY
62
- end
63
- end
64
- end
65
-
66
- # Defines class-level inheritable attribute writer. Attributes are available to subclasses,
67
- # each subclass has a copy of parent's attribute.
68
- #
69
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to
70
- # define inheritable writer for.
71
- # @option syms :instance_writer<Boolean> if true, instance-level inheritable attribute writer is defined.
72
- # @return <Array[#to_s]> An Array of the attributes that were made into inheritable writers.
73
- #
74
- # @api public
75
- #
76
- # @todo We need a style for class_eval <<-HEREDOC. I'd like to make it
77
- # class_eval(<<-RUBY, __FILE__, __LINE__), but we should codify it somewhere.
78
- def couchrest_inheritable_writer(*ivars)
79
- instance_writer = ivars.pop[:writer] if ivars.last.is_a?(Hash)
80
- ivars.each do |ivar|
81
- unless self.respond_to?("#{ivar}=".to_sym)
82
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
83
- def self.#{ivar}=(obj)
84
- @#{ivar} = obj
85
- end
86
- RUBY
87
- end
88
-
89
- unless self.method_defined?("#{ivar}=".to_sym)
90
- unless instance_writer == false
91
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
92
- def #{ivar}=(obj) self.class.#{ivar} = obj end
93
- RUBY
94
- end
95
- end
96
-
97
- self.send("#{ivar}=", yield) if block_given?
98
- end
99
- end
100
-
101
- # Defines class-level inheritable attribute accessor. Attributes are available to subclasses,
102
- # each subclass has a copy of parent's attribute.
103
- #
104
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to
105
- # define inheritable accessor for.
106
- # @option syms :instance_writer<Boolean> if true, instance-level inheritable attribute writer is defined.
107
- # @return <Array[#to_s]> An Array of attributes turned into inheritable accessors.
108
- #
109
- # @api public
110
- def couchrest_inheritable_accessor(*syms, &block)
111
- couchrest_inheritable_reader(*syms)
112
- couchrest_inheritable_writer(*syms, &block)
113
- end
114
- end
115
- end