bsm-models 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e2ceca071140a27ffd3ec6767e726b890491f726
4
+ data.tar.gz: 51536dee838ad39c97905a1950303a2ca11c9fd3
5
+ SHA512:
6
+ metadata.gz: fc905253548fa5946306ae4936bce3d38ecacd687fc2891ee4b9aa0f7da0f39c3ff837baef8312cf5f696b36e1dae690f1ca2aa058968a926202d180f0c552fd
7
+ data.tar.gz: 306c540b9ab2615aec5aed158f01c3fe2502e093bd19b3509686699c89b4afc818367b88d4ca3f9e115b0057db2c0b4a784531bd3c981c2fc778801c4fe499b3
@@ -5,18 +5,27 @@ module Bsm::Model::HasManySerialized
5
5
 
6
6
  module ClassMethods
7
7
 
8
- def has_many_serialized(name, options = {})
9
- ActiveRecord::VERSION::STRING < '4.0.0' ? Builder.build(self, name.to_sym, options) : Builder.build(self, name.to_sym, options, {})
8
+ def has_many_serialized(name, scope = nil, options = {})
9
+ Builder.build(self, name, scope, options)
10
10
  end
11
11
 
12
12
  end
13
13
 
14
- class Builder < ActiveRecord::Associations::Builder::Association
14
+ class Builder < ActiveRecord::Associations::Builder::CollectionAssociation
15
15
 
16
16
  def build
17
- validate_options
18
17
  serialize_attribute
19
- define_accessors
18
+ super.tap do
19
+ define_accessors
20
+ end
21
+ end
22
+
23
+ def macro
24
+ :has_many
25
+ end
26
+
27
+ def valid_dependent_options
28
+ []
20
29
  end
21
30
 
22
31
  protected
@@ -25,20 +34,20 @@ module Bsm::Model::HasManySerialized
25
34
  model.serialize attribute_name, ::Bsm::Model::Coders::JsonColumn.new(Array)
26
35
  end
27
36
 
37
+ def define_accessors
38
+ super if reflection
39
+ end
40
+
28
41
  def define_readers
29
- name, attribute_name, klass = self.name, self.attribute_name, self.klass
42
+ name, attribute_name, klass = self.name, self.attribute_name, reflection.klass
30
43
 
31
44
  model.redefine_method(name) do
32
45
  klass.where(klass.primary_key => send(attribute_name))
33
46
  end
34
-
35
- model.redefine_method(attribute_name) do
36
- read_attribute(attribute_name)
37
- end if ActiveRecord::VERSION::STRING < "3.2.0"
38
47
  end
39
48
 
40
49
  def define_writers
41
- name, attribute_name, klass = self.name, self.attribute_name, self.klass
50
+ name, attribute_name, klass = self.name, self.attribute_name, reflection.klass
42
51
 
43
52
  model.redefine_method("#{name}=") do |records|
44
53
  records = Array.wrap(records)
@@ -58,13 +67,5 @@ module Bsm::Model::HasManySerialized
58
67
  @attribute_name ||= "#{name.to_s.singularize}_ids"
59
68
  end
60
69
 
61
- def klass
62
- @klass ||= class_name.constantize
63
- end
64
-
65
- def class_name
66
- @class_name ||= options[:class_name] || name.to_s.singularize.camelize
67
- end
68
-
69
70
  end
70
- end
71
+ end
metadata CHANGED
@@ -1,110 +1,109 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsm-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dimitrij Denissenko
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-11 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: abstract
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activerecord
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: 3.1.0
33
+ version: 4.0.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 4.1.0
38
37
  type: :runtime
39
38
  prerelease: false
40
39
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
40
  requirements:
43
- - - ! '>='
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 4.0.0
44
+ - - "<"
44
45
  - !ruby/object:Gem::Version
45
- version: 3.1.0
46
+ version: 4.1.0
46
47
  - !ruby/object:Gem::Dependency
47
48
  name: railties
48
49
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 3.1.0
53
+ version: 4.0.0
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 4.1.0
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
60
  requirements:
59
- - - ! '>='
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 4.0.0
64
+ - - "<"
60
65
  - !ruby/object:Gem::Version
61
- version: 3.1.0
66
+ version: 4.1.0
62
67
  - !ruby/object:Gem::Dependency
63
68
  name: rspec
64
69
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
70
  requirements:
67
- - - ! '>='
71
+ - - ">="
68
72
  - !ruby/object:Gem::Version
69
73
  version: '0'
70
74
  type: :development
71
75
  prerelease: false
72
76
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
77
  requirements:
75
- - - ! '>='
78
+ - - ">="
76
79
  - !ruby/object:Gem::Version
77
80
  version: '0'
78
81
  - !ruby/object:Gem::Dependency
79
82
  name: sqlite3
80
83
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
84
  requirements:
83
- - - ! '>='
85
+ - - ">="
84
86
  - !ruby/object:Gem::Version
85
87
  version: '0'
86
88
  type: :development
87
89
  prerelease: false
88
90
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
91
  requirements:
91
- - - ! '>='
92
+ - - ">="
92
93
  - !ruby/object:Gem::Version
93
94
  version: '0'
94
95
  - !ruby/object:Gem::Dependency
95
96
  name: shoulda-matchers
96
97
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
98
  requirements:
99
- - - ! '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
105
  requirements:
107
- - - ! '>='
106
+ - - ">="
108
107
  - !ruby/object:Gem::Version
109
108
  version: '0'
110
109
  description: ''
@@ -113,43 +112,41 @@ executables: []
113
112
  extensions: []
114
113
  extra_rdoc_files: []
115
114
  files:
115
+ - lib/bsm-models.rb
116
116
  - lib/bsm/model.rb
117
- - lib/bsm/model/editable.rb
118
- - lib/bsm/model/locale/en.yml
119
117
  - lib/bsm/model/abstract.rb
120
118
  - lib/bsm/model/coders.rb
119
+ - lib/bsm/model/coders/abstract_column.rb
120
+ - lib/bsm/model/coders/json_column.rb
121
+ - lib/bsm/model/coders/marshal_column.rb
121
122
  - lib/bsm/model/deletable.rb
122
123
  - lib/bsm/model/eager_descendants.rb
124
+ - lib/bsm/model/editable.rb
123
125
  - lib/bsm/model/has_many_serialized.rb
126
+ - lib/bsm/model/locale/en.yml
124
127
  - lib/bsm/model/sti_convertable.rb
125
- - lib/bsm/model/coders/marshal_column.rb
126
- - lib/bsm/model/coders/abstract_column.rb
127
- - lib/bsm/model/coders/json_column.rb
128
- - lib/bsm-models.rb
129
128
  - lib/bsm_models.rb
130
129
  homepage: https://github.com/bsm/models
131
130
  licenses: []
131
+ metadata: {}
132
132
  post_install_message:
133
133
  rdoc_options: []
134
134
  require_paths:
135
135
  - lib
136
136
  required_ruby_version: !ruby/object:Gem::Requirement
137
- none: false
138
137
  requirements:
139
- - - ! '>='
138
+ - - ">="
140
139
  - !ruby/object:Gem::Version
141
- version: 1.9.2
140
+ version: 2.0.0
142
141
  required_rubygems_version: !ruby/object:Gem::Requirement
143
- none: false
144
142
  requirements:
145
- - - ! '>='
143
+ - - ">="
146
144
  - !ruby/object:Gem::Version
147
- version: 1.3.6
145
+ version: 1.8.0
148
146
  requirements: []
149
147
  rubyforge_project:
150
- rubygems_version: 1.8.25
148
+ rubygems_version: 2.2.2
151
149
  signing_key:
152
- specification_version: 3
150
+ specification_version: 4
153
151
  summary: BSM's very custom model extensions
154
152
  test_files: []
155
- has_rdoc: