@@ -28,7 +28,7 @@ def initialize(model, context = nil)
2828 end
2929
3030 def id
31- model . send ( self . class . _primary_key )
31+ model . public_send ( self . class . _primary_key )
3232 end
3333
3434 def is_new?
@@ -112,7 +112,7 @@ def fetchable_fields
112112 # Override this on a resource to customize how the associated records
113113 # are fetched for a model. Particularly helpful for authorization.
114114 def records_for ( association_name , _options = { } )
115- model . send association_name
115+ model . public_send association_name
116116 end
117117
118118 private
@@ -166,9 +166,9 @@ def _create_has_many_links(association_type, association_key_values)
166166 related_resource = association . resource_klass . find_by_key ( association_key_value , context : @context )
167167
168168 # TODO: Add option to skip relations that already exist instead of returning an error?
169- relation = @model . send ( association . type ) . where ( association . primary_key => association_key_value ) . first
169+ relation = @model . public_send ( association . type ) . where ( association . primary_key => association_key_value ) . first
170170 if relation . nil?
171- @model . send ( association . type ) << related_resource . model
171+ @model . public_send ( association . type ) << related_resource . model
172172 else
173173 fail JSONAPI ::Exceptions ::HasManyRelationExists . new ( association_key_value )
174174 end
@@ -198,8 +198,8 @@ def _replace_has_one_link(association_type, association_key_value)
198198 def _replace_polymorphic_has_one_link ( association_type , key_value , key_type )
199199 association = self . class . _associations [ association_type . to_sym ]
200200
201- model . send ( "#{ association . foreign_key } =" , key_value )
202- model . send ( "#{ association . polymorphic_type } =" , key_type . to_s . classify )
201+ model . public_send ( "#{ association . foreign_key } =" , key_value )
202+ model . public_send ( "#{ association . polymorphic_type } =" , key_type . to_s . classify )
203203
204204 @save_needed = true
205205
@@ -209,7 +209,7 @@ def _replace_polymorphic_has_one_link(association_type, key_value, key_type)
209209 def _remove_has_many_link ( association_type , key )
210210 association = self . class . _associations [ association_type ]
211211
212- @model . send ( association . type ) . delete ( key )
212+ @model . public_send ( association . type ) . delete ( key )
213213
214214 :completed
215215 end
@@ -314,11 +314,11 @@ def attribute(attr, options = {})
314314 @_attributes ||= { }
315315 @_attributes [ attr ] = options
316316 define_method attr do
317- @model . send ( attr )
317+ @model . public_send ( attr )
318318 end unless method_defined? ( attr )
319319
320320 define_method "#{ attr } =" do |value |
321- @model . send "#{ attr } =" , value
321+ @model . public_send "#{ attr } =" , value
322322 end unless method_defined? ( "#{ attr } =" )
323323 end
324324
@@ -696,7 +696,7 @@ def _associate(klass, *attrs)
696696 define_method foreign_key do
697697 records = public_send ( associated_records_method_name )
698698 return records . collect do |record |
699- record . send ( association . resource_klass . _primary_key )
699+ record . public_send ( association . resource_klass . _primary_key )
700700 end
701701 end unless method_defined? ( foreign_key )
702702 define_method attr do |options = { } |
0 commit comments