Module: ActiveRecord::PLSQL::Pipelined

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_record/plsql/pipelined.rb

Defined Under Namespace

Modules: ClassMethods Classes: PipelinedFunctionError, PipelinedFunctionTableName

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#found_by_argumentsObject

Returns the value of attribute found_by_arguments.



109
110
111
# File 'lib/active_record/plsql/pipelined.rb', line 109

def found_by_arguments
  @found_by_arguments
end

Instance Method Details

#reload(options = nil) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/active_record/plsql/pipelined.rb', line 111

def reload(options = nil)
  return super unless pipelined? && (found_by_arguments.present? || options)

  clear_aggregation_cache
  clear_association_cache

  ActiveRecord::IdentityMap.without do
    fresh_object = self.class.unscoped do
      relation = self.class.where(self.class.primary_key => id)

      if found_by_arguments
        relation.bind_values += found_by_arguments
        relation.to_a.first
      else
        relation.where(options).to_a.first
      end
    end

    @attributes.update(fresh_object.instance_variable_get('@attributes'))
  end

  @attributes_cache = {}
  self
end