ohm-contrib 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Ohm
2
2
  module Contrib
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
 
6
6
  autoload :ActiveModelExtension, "ohm/contrib/active_model_extension"
@@ -18,4 +18,4 @@ module Ohm
18
18
  autoload :Scope, "ohm/contrib/scope"
19
19
  autoload :SoftDelete, "ohm/contrib/soft_delete"
20
20
  autoload :FulltextSearching, "ohm/contrib/fulltext_searching"
21
- end
21
+ end
@@ -11,18 +11,22 @@ require "active_model"
11
11
  # end
12
12
  module Ohm
13
13
  module ActiveModelExtension
14
+ def self.included(model)
15
+ model.extend ActiveModel::Naming
16
+ end
17
+
14
18
  def to_model
15
19
  ActiveModelInterface.new(self)
16
20
  end
17
21
  end
18
22
 
19
23
  class ActiveModelInterface
24
+ extend ActiveModel::Naming
25
+
20
26
  def initialize(model)
21
27
  @model = model
22
28
  end
23
29
 
24
- extend ActiveModel::Naming
25
-
26
30
  def to_model
27
31
  self
28
32
  end
@@ -80,4 +84,4 @@ module Ohm
80
84
  end
81
85
  end
82
86
  end
83
- end
87
+ end
@@ -29,8 +29,8 @@ module Ohm
29
29
  # * Boolean
30
30
  module Types
31
31
  def self.defined?(type)
32
- @constants ||= constants.map(&:to_s)
33
- @constants.include?(type.to_s)
32
+ @_constants ||= constants.map { |c| c.to_sym }
33
+ @_constants.include?(type.to_sym)
34
34
  end
35
35
 
36
36
  def self.[](type)
@@ -58,7 +58,7 @@ module Ohm
58
58
  end
59
59
 
60
60
  def self.delegate_to(klass, except = @@delegation_blacklist)
61
- methods = klass.public_instance_methods.map(&:to_sym) - except
61
+ methods = klass.public_instance_methods.map { |e| e.to_sym } - except
62
62
  def_delegators :object, *methods
63
63
  end
64
64
 
@@ -340,9 +340,14 @@ module Ohm
340
340
  end
341
341
 
342
342
  attributes << name unless attributes.include?(name)
343
+ types[name] = type
343
344
  end
344
345
  alias :typecast :attribute
345
346
 
347
+ def types
348
+ @types ||= {}
349
+ end
350
+
346
351
  private
347
352
  def const_missing(name)
348
353
  if Ohm::Types.defined?(name)
@@ -23,3 +23,5 @@ class ActiveModelTest < Test::Unit::TestCase
23
23
  @model = Post.new
24
24
  end
25
25
  end
26
+
27
+
@@ -1,8 +1,10 @@
1
- require 'cutest'
2
- require 'redis'
3
- require 'ohm'
4
- require 'ohm/contrib'
5
- require 'override'
1
+ $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
2
+
3
+ require "cutest"
4
+ require "redis"
5
+ require "ohm"
6
+ require "ohm/contrib"
7
+ require "override"
6
8
 
7
9
  Ohm.connect :host => "localhost", :port => 6379, :db => 1
8
10
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohm-contrib
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
4
+ prerelease:
5
+ version: 0.1.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Cyril David
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-08 00:00:00 +08:00
13
+ date: 2011-02-09 00:00:00 +08:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,8 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
24
  version: "0"
31
25
  type: :runtime
32
26
  version_requirements: *id001
@@ -38,8 +32,6 @@ dependencies:
38
32
  requirements:
39
33
  - - ">="
40
34
  - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
35
  version: "0"
44
36
  type: :development
45
37
  version_requirements: *id002
@@ -51,8 +43,6 @@ dependencies:
51
43
  requirements:
52
44
  - - ">="
53
45
  - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
46
  version: "0"
57
47
  type: :development
58
48
  version_requirements: *id003
@@ -64,8 +54,6 @@ dependencies:
64
54
  requirements:
65
55
  - - ">="
66
56
  - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
57
  version: "0"
70
58
  type: :development
71
59
  version_requirements: *id004
@@ -77,8 +65,6 @@ dependencies:
77
65
  requirements:
78
66
  - - ">="
79
67
  - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
68
  version: "0"
83
69
  type: :development
84
70
  version_requirements: *id005
@@ -153,21 +139,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
139
  requirements:
154
140
  - - ">="
155
141
  - !ruby/object:Gem::Version
156
- segments:
157
- - 0
158
142
  version: "0"
159
143
  required_rubygems_version: !ruby/object:Gem::Requirement
160
144
  none: false
161
145
  requirements:
162
146
  - - ">="
163
147
  - !ruby/object:Gem::Version
164
- segments:
165
- - 0
166
148
  version: "0"
167
149
  requirements: []
168
150
 
169
151
  rubyforge_project: ohm-contrib
170
- rubygems_version: 1.3.7
152
+ rubygems_version: 1.5.0
171
153
  signing_key:
172
154
  specification_version: 2
173
155
  summary: A collection of decoupled drop-in modules for Ohm.