Sha256: 883cad138d5084bc509d10ecafd01e61ccc5578fc62972be7baa0e3f04708406

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

module Grape
  module Roar
    module Extensions
      module Relations
        module Adapters
          class ActiveRecord < Base
            include Validations::ActiveRecord

            valid_for { |klass| klass < ::ActiveRecord::Base }

            def collection_methods
              @collection_methods ||= %i[has_many has_and_belongs_to_many]
            end

            def name_for_represented(represented)
              klass_name = case represented
                           when ::ActiveRecord::Relation
                             represented.klass.name
                           else
                             represented.class.name
                           end
              klass_name.demodulize.pluralize.downcase
            end

            def single_entity_methods
              @single_entity_methods ||= %i[has_one belongs_to]
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-roar-0.4.1 lib/grape/roar/extensions/relations/adapters/active_record.rb