Sha256: ba0525f4a4289256d8fb81cded7a9d09798114769617761d6747198f1d2df52f

Contents?: true

Size: 922 Bytes

Versions: 2

Compression:

Stored size: 922 Bytes

Contents

module Troo
  module RemoteModelHelpers
    module ClassMethods
      def with_collection(resources = [])
        resources.map { |resource| new(resource) }
      end

      def all
        {}
      end

      def by_board_id
        {}
      end

      def by_list_id
        {}
      end

      def by_card_id
        {}
      end

      def by_member_id
        {}
      end
    end

    module InstanceMethods
      def preprocess
        associations.map do |association|
          associated(association).map { |record| record.preprocess }
        end

        Persistence::Local.persist(self)
      end

      def local
        @local ||= local_model.by_external_id(id)
      end

      private

      def associated(association)
        Array(send(association))
      end
    end

    def self.included(receiver)
      receiver.extend(ClassMethods)
      receiver.send(:include, InstanceMethods)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
troo-0.0.10 lib/troo/helpers/remote_model_helpers.rb
troo-0.0.9 lib/troo/helpers/remote_model_helpers.rb