brainstem 0.2.6.1 → 1.0.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/CHANGELOG.md +16 -2
- data/Gemfile.lock +51 -36
- data/README.md +531 -110
- data/brainstem.gemspec +6 -2
- data/lib/brainstem.rb +25 -9
- data/lib/brainstem/concerns/controller_param_management.rb +22 -0
- data/lib/brainstem/concerns/error_presentation.rb +58 -0
- data/lib/brainstem/concerns/inheritable_configuration.rb +29 -0
- data/lib/brainstem/concerns/lookup.rb +30 -0
- data/lib/brainstem/concerns/presenter_dsl.rb +111 -0
- data/lib/brainstem/controller_methods.rb +17 -8
- data/lib/brainstem/dsl/association.rb +55 -0
- data/lib/brainstem/dsl/associations_block.rb +12 -0
- data/lib/brainstem/dsl/base_block.rb +31 -0
- data/lib/brainstem/dsl/conditional.rb +25 -0
- data/lib/brainstem/dsl/conditionals_block.rb +15 -0
- data/lib/brainstem/dsl/configuration.rb +112 -0
- data/lib/brainstem/dsl/field.rb +68 -0
- data/lib/brainstem/dsl/fields_block.rb +25 -0
- data/lib/brainstem/preloader.rb +98 -0
- data/lib/brainstem/presenter.rb +325 -134
- data/lib/brainstem/presenter_collection.rb +82 -286
- data/lib/brainstem/presenter_validator.rb +96 -0
- data/lib/brainstem/query_strategies/README.md +107 -0
- data/lib/brainstem/query_strategies/base_strategy.rb +62 -0
- data/lib/brainstem/query_strategies/filter_and_search.rb +50 -0
- data/lib/brainstem/query_strategies/filter_or_search.rb +103 -0
- data/lib/brainstem/test_helpers.rb +5 -1
- data/lib/brainstem/version.rb +1 -1
- data/spec/brainstem/concerns/controller_param_management_spec.rb +42 -0
- data/spec/brainstem/concerns/error_presentation_spec.rb +113 -0
- data/spec/brainstem/concerns/inheritable_configuration_spec.rb +210 -0
- data/spec/brainstem/concerns/presenter_dsl_spec.rb +412 -0
- data/spec/brainstem/controller_methods_spec.rb +15 -27
- data/spec/brainstem/dsl/association_spec.rb +123 -0
- data/spec/brainstem/dsl/conditional_spec.rb +93 -0
- data/spec/brainstem/dsl/configuration_spec.rb +1 -0
- data/spec/brainstem/dsl/field_spec.rb +212 -0
- data/spec/brainstem/preloader_spec.rb +137 -0
- data/spec/brainstem/presenter_collection_spec.rb +565 -244
- data/spec/brainstem/presenter_spec.rb +726 -167
- data/spec/brainstem/presenter_validator_spec.rb +209 -0
- data/spec/brainstem/query_strategies/filter_and_search_spec.rb +46 -0
- data/spec/brainstem/query_strategies/filter_or_search_spec.rb +45 -0
- data/spec/spec_helper.rb +11 -3
- data/spec/spec_helpers/db.rb +32 -65
- data/spec/spec_helpers/presenters.rb +124 -29
- data/spec/spec_helpers/rr.rb +11 -0
- data/spec/spec_helpers/schema.rb +115 -0
- metadata +126 -30
- data/lib/brainstem/association_field.rb +0 -53
- data/lib/brainstem/engine.rb +0 -4
- data/pkg/brainstem-0.2.5.gem +0 -0
- data/pkg/brainstem-0.2.6.gem +0 -0
- data/spec/spec_helpers/cleanup.rb +0 -23
@@ -0,0 +1,115 @@
|
|
1
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
2
|
+
ActiveRecord::Schema.define do
|
3
|
+
self.verbose = false
|
4
|
+
|
5
|
+
create_table :users, :force => true do |t|
|
6
|
+
t.string :username
|
7
|
+
t.timestamps null: true
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table :workspaces, :force => true do |t|
|
11
|
+
t.string :type
|
12
|
+
t.string :title
|
13
|
+
t.string :description
|
14
|
+
t.belongs_to :user
|
15
|
+
t.timestamps null: true
|
16
|
+
end
|
17
|
+
|
18
|
+
create_table :tasks, :force => true do |t|
|
19
|
+
t.string :name
|
20
|
+
t.integer :parent_id
|
21
|
+
t.belongs_to :workspace
|
22
|
+
t.timestamps null: true
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table :posts, :force => true do |t|
|
26
|
+
t.string :body
|
27
|
+
t.integer :subject_id
|
28
|
+
t.string :subject_type
|
29
|
+
t.integer :user_id
|
30
|
+
t.timestamps null: true
|
31
|
+
end
|
32
|
+
|
33
|
+
create_table :attachments, :force => true do |t|
|
34
|
+
t.string :type, null: false
|
35
|
+
t.string :filename
|
36
|
+
t.integer :subject_id
|
37
|
+
t.string :subject_type
|
38
|
+
t.timestamps null: true
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table :cheeses, force: true do |t|
|
42
|
+
t.integer :user_id
|
43
|
+
t.string :flavor
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class User < ActiveRecord::Base
|
48
|
+
has_many :workspaces
|
49
|
+
end
|
50
|
+
|
51
|
+
class Task < ActiveRecord::Base
|
52
|
+
belongs_to :workspace
|
53
|
+
has_many :sub_tasks, :foreign_key => :parent_id, :class_name => "Task"
|
54
|
+
has_many :posts
|
55
|
+
|
56
|
+
def tags
|
57
|
+
%w[some tags]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Workspace < ActiveRecord::Base
|
62
|
+
belongs_to :user
|
63
|
+
has_many :tasks
|
64
|
+
has_many :posts
|
65
|
+
|
66
|
+
scope :owned_by, -> id { where(:user_id => id) }
|
67
|
+
scope :numeric_description, -> description { where(:description => ["1", "2", "3"]) }
|
68
|
+
|
69
|
+
def secret_info
|
70
|
+
"this is secret!"
|
71
|
+
end
|
72
|
+
|
73
|
+
def lead_user
|
74
|
+
user
|
75
|
+
end
|
76
|
+
|
77
|
+
def missing_user
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class Group < Workspace
|
83
|
+
def secret_info
|
84
|
+
"groups have different secret info"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class Post < ActiveRecord::Base
|
89
|
+
belongs_to :user
|
90
|
+
belongs_to :subject, polymorphic: true
|
91
|
+
has_many :attachments, as: :subject, class_name: 'Attachments::PostAttachment'
|
92
|
+
|
93
|
+
def things
|
94
|
+
[Workspace.first, Post.first, Task.first]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class Cheese < ActiveRecord::Base
|
99
|
+
belongs_to :user
|
100
|
+
|
101
|
+
scope :owned_by, -> id { where(user_id: id) }
|
102
|
+
end
|
103
|
+
|
104
|
+
module Attachments
|
105
|
+
class Base < ActiveRecord::Base
|
106
|
+
self.table_name = :attachments
|
107
|
+
belongs_to :subject, polymorphic: true
|
108
|
+
end
|
109
|
+
|
110
|
+
class PostAttachment < Base
|
111
|
+
end
|
112
|
+
|
113
|
+
class TaskAttachment < Base
|
114
|
+
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,111 +1,167 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brainstem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mavenlink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: redcarpet
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rr
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
103
|
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- -
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
112
|
+
name: database_cleaner
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
|
-
- -
|
115
|
+
- - ">="
|
88
116
|
- !ruby/object:Gem::Version
|
89
117
|
version: '0'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
|
-
- -
|
122
|
+
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: yard
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
|
-
- -
|
129
|
+
- - ">="
|
102
130
|
- !ruby/object:Gem::Version
|
103
131
|
version: '0'
|
104
132
|
type: :development
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
|
-
- -
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-nav
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
109
165
|
- !ruby/object:Gem::Version
|
110
166
|
version: '0'
|
111
167
|
description: Brainstem allows you to create rich API presenters that know how to filter,
|
@@ -125,25 +181,53 @@ files:
|
|
125
181
|
- Rakefile
|
126
182
|
- brainstem.gemspec
|
127
183
|
- lib/brainstem.rb
|
128
|
-
- lib/brainstem/
|
184
|
+
- lib/brainstem/concerns/controller_param_management.rb
|
185
|
+
- lib/brainstem/concerns/error_presentation.rb
|
186
|
+
- lib/brainstem/concerns/inheritable_configuration.rb
|
187
|
+
- lib/brainstem/concerns/lookup.rb
|
188
|
+
- lib/brainstem/concerns/presenter_dsl.rb
|
129
189
|
- lib/brainstem/controller_methods.rb
|
130
|
-
- lib/brainstem/
|
190
|
+
- lib/brainstem/dsl/association.rb
|
191
|
+
- lib/brainstem/dsl/associations_block.rb
|
192
|
+
- lib/brainstem/dsl/base_block.rb
|
193
|
+
- lib/brainstem/dsl/conditional.rb
|
194
|
+
- lib/brainstem/dsl/conditionals_block.rb
|
195
|
+
- lib/brainstem/dsl/configuration.rb
|
196
|
+
- lib/brainstem/dsl/field.rb
|
197
|
+
- lib/brainstem/dsl/fields_block.rb
|
198
|
+
- lib/brainstem/preloader.rb
|
131
199
|
- lib/brainstem/presenter.rb
|
132
200
|
- lib/brainstem/presenter_collection.rb
|
201
|
+
- lib/brainstem/presenter_validator.rb
|
202
|
+
- lib/brainstem/query_strategies/README.md
|
203
|
+
- lib/brainstem/query_strategies/base_strategy.rb
|
204
|
+
- lib/brainstem/query_strategies/filter_and_search.rb
|
205
|
+
- lib/brainstem/query_strategies/filter_or_search.rb
|
133
206
|
- lib/brainstem/search_unavailable_error.rb
|
134
207
|
- lib/brainstem/test_helpers.rb
|
135
208
|
- lib/brainstem/time_classes.rb
|
136
209
|
- lib/brainstem/version.rb
|
137
|
-
-
|
138
|
-
-
|
210
|
+
- spec/brainstem/concerns/controller_param_management_spec.rb
|
211
|
+
- spec/brainstem/concerns/error_presentation_spec.rb
|
212
|
+
- spec/brainstem/concerns/inheritable_configuration_spec.rb
|
213
|
+
- spec/brainstem/concerns/presenter_dsl_spec.rb
|
139
214
|
- spec/brainstem/controller_methods_spec.rb
|
215
|
+
- spec/brainstem/dsl/association_spec.rb
|
216
|
+
- spec/brainstem/dsl/conditional_spec.rb
|
217
|
+
- spec/brainstem/dsl/configuration_spec.rb
|
218
|
+
- spec/brainstem/dsl/field_spec.rb
|
219
|
+
- spec/brainstem/preloader_spec.rb
|
140
220
|
- spec/brainstem/presenter_collection_spec.rb
|
141
221
|
- spec/brainstem/presenter_spec.rb
|
222
|
+
- spec/brainstem/presenter_validator_spec.rb
|
223
|
+
- spec/brainstem/query_strategies/filter_and_search_spec.rb
|
224
|
+
- spec/brainstem/query_strategies/filter_or_search_spec.rb
|
142
225
|
- spec/brainstem_spec.rb
|
143
226
|
- spec/spec_helper.rb
|
144
|
-
- spec/spec_helpers/cleanup.rb
|
145
227
|
- spec/spec_helpers/db.rb
|
146
228
|
- spec/spec_helpers/presenters.rb
|
229
|
+
- spec/spec_helpers/rr.rb
|
230
|
+
- spec/spec_helpers/schema.rb
|
147
231
|
homepage: http://github.com/mavenlink/brainstem
|
148
232
|
licenses:
|
149
233
|
- MIT
|
@@ -154,27 +238,39 @@ require_paths:
|
|
154
238
|
- lib
|
155
239
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
240
|
requirements:
|
157
|
-
- -
|
241
|
+
- - ">="
|
158
242
|
- !ruby/object:Gem::Version
|
159
243
|
version: '0'
|
160
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
245
|
requirements:
|
162
|
-
- -
|
246
|
+
- - ">"
|
163
247
|
- !ruby/object:Gem::Version
|
164
|
-
version:
|
248
|
+
version: 1.3.1
|
165
249
|
requirements: []
|
166
250
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
251
|
+
rubygems_version: 2.4.8
|
168
252
|
signing_key:
|
169
253
|
specification_version: 4
|
170
254
|
summary: ActiveRecord presenters with a rich request API
|
171
255
|
test_files:
|
256
|
+
- spec/brainstem/concerns/controller_param_management_spec.rb
|
257
|
+
- spec/brainstem/concerns/error_presentation_spec.rb
|
258
|
+
- spec/brainstem/concerns/inheritable_configuration_spec.rb
|
259
|
+
- spec/brainstem/concerns/presenter_dsl_spec.rb
|
172
260
|
- spec/brainstem/controller_methods_spec.rb
|
261
|
+
- spec/brainstem/dsl/association_spec.rb
|
262
|
+
- spec/brainstem/dsl/conditional_spec.rb
|
263
|
+
- spec/brainstem/dsl/configuration_spec.rb
|
264
|
+
- spec/brainstem/dsl/field_spec.rb
|
265
|
+
- spec/brainstem/preloader_spec.rb
|
173
266
|
- spec/brainstem/presenter_collection_spec.rb
|
174
267
|
- spec/brainstem/presenter_spec.rb
|
268
|
+
- spec/brainstem/presenter_validator_spec.rb
|
269
|
+
- spec/brainstem/query_strategies/filter_and_search_spec.rb
|
270
|
+
- spec/brainstem/query_strategies/filter_or_search_spec.rb
|
175
271
|
- spec/brainstem_spec.rb
|
176
272
|
- spec/spec_helper.rb
|
177
|
-
- spec/spec_helpers/cleanup.rb
|
178
273
|
- spec/spec_helpers/db.rb
|
179
274
|
- spec/spec_helpers/presenters.rb
|
180
|
-
|
275
|
+
- spec/spec_helpers/rr.rb
|
276
|
+
- spec/spec_helpers/schema.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Brainstem
|
2
|
-
# AssociationField acts as a standin for associations.
|
3
|
-
# @api private
|
4
|
-
class AssociationField
|
5
|
-
# @!attribute [r] method_name
|
6
|
-
# @return [String] The name of the method that is being proxied.
|
7
|
-
attr_reader :method_name
|
8
|
-
|
9
|
-
# @!attribute [rw] ignore_type
|
10
|
-
# @return [Boolean] When true, polymorphic associations will be treated like normal ones,
|
11
|
-
# skipping the _ref structure and simply using [json_name]_id.
|
12
|
-
attr_accessor :ignore_type
|
13
|
-
|
14
|
-
# @!attribute [rw] json_name
|
15
|
-
# @return [String] The name of the top-level JSON key for objects provided by this association.
|
16
|
-
attr_accessor :json_name
|
17
|
-
|
18
|
-
# @!attribute [rw] restrict_to_only
|
19
|
-
# @return [Boolean] Option for this association to be restricted to only queries.
|
20
|
-
attr_accessor :restrict_to_only
|
21
|
-
|
22
|
-
# @!attribute [r] block
|
23
|
-
# @return [Proc] The block to be called when fetching models instead of calling a method on the model
|
24
|
-
attr_reader :block
|
25
|
-
|
26
|
-
# @param method_name The name of the method being proxied. Not required if
|
27
|
-
# a block is passed instead.
|
28
|
-
# @option options [Boolean] :json_name The name of the top-level JSON key for objects provided by this association.
|
29
|
-
def initialize(*args, &block)
|
30
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
31
|
-
method_name = args.first.to_sym if args.first.is_a?(String) || args.first.is_a?(Symbol)
|
32
|
-
@json_name = options[:json_name]
|
33
|
-
@ignore_type = options[:ignore_type] || false
|
34
|
-
@restrict_to_only = options[:restrict_to_only] || false
|
35
|
-
if block_given?
|
36
|
-
raise ArgumentError, "options[:json_name] is required when using a block" unless options[:json_name]
|
37
|
-
raise ArgumentError, "Method name is invalid with a block" if method_name
|
38
|
-
@block = block
|
39
|
-
elsif method_name
|
40
|
-
@method_name = method_name
|
41
|
-
else
|
42
|
-
raise ArgumentError, "Method name or block is required"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Call the method or block being proxied.
|
47
|
-
# @param model The object to call the proxied method on.
|
48
|
-
# @return The value returned by calling the method or block being proxied.
|
49
|
-
def call(model)
|
50
|
-
@block ? @block.call(model) : model.send(@method_name)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|