Sha256: da34d122ac74db41ca65f56499ec6e1ab45c43c70195a947de878ea8be2209d4

Contents?: true

Size: 639 Bytes

Versions: 4

Compression:

Stored size: 639 Bytes

Contents

module Kangaroo
  module Model
    module RemoteExecute
      def call name, *args
        return_value = remote.send name, ids_for_execute, *args
        
        # TODO: handle warnings etc
        if Hash === return_value && return_value[:value]
          handle_updated_values return_value[:value] 
          self
        else
          return_value
        end
      end
      
      protected
      def handle_updated_values values
        values.each do |key, value|
          write_attribute key, value
        end
      end
      
      private
      def ids_for_execute
        new_record? ? [] : [id]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kangaroo-0.0.3 lib/kangaroo/model/remote_execute.rb
kangaroo-0.0.2 lib/kangaroo/model/remote_execute.rb
kangaroo-0.0.1.pre2 lib/kangaroo/model/remote_execute.rb
kangaroo-0.0.1.pre lib/kangaroo/model/remote_execute.rb