hyper-mesh icon indicating copy to clipboard operation
hyper-mesh copied to clipboard

implement alias_attribute

Open catmando opened this issue 7 years ago • 1 comments

catmando avatar Mar 10 '18 18:03 catmando

Also support Model#load for aliased attributes like:

module ActiveRecord
  module InstanceMethods
    def load(*attributes, &block)
      first_time = true
      ReactiveRecord.load do
        results = attributes.collect { |attr| send("#{model._dealias_attribute(attr)}#{'!' if first_time}") }
        results = yield(*results) if block
        first_time = false
        block.nil? && results.count == 1 ? results.first : results
      end
    end
  end
end

mpantel avatar May 28 '18 17:05 mpantel