Sha256: 369bfd9507deb465ab5cd30c6126ccb9eb6f187202466a16480222be679666e1

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module Datagrid
  # Required to be ActiveModel compatible
  module ActiveModel
    extend ActiveSupport::Concern

    included do
      require "active_model/naming"
      extend ::ActiveModel::Naming
    end

    module ClassMethods
      # @return [String] URL query parameter name of the grid class
      def param_name
        to_s.underscore.tr("/", "_")
      end
    end

    # @return [String] URL query parameter name of the grid class
    def param_name
      self.class.param_name
    end

    # @return [String] URL query parameter name of the grid class
    def param_key
      param_name
    end

    def to_key
      [self.class.param_name]
    end

    def persisted?
      false
    end

    def to_model
      self
    end

    def to_param
      param_name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
datagrid-2.0.0 lib/datagrid/active_model.rb
datagrid-2.0.0.pre.alpha lib/datagrid/active_model.rb