Sha256: d1c8264cbf3688b5f9c22c2d719fac3812e2d502152d5b2c8026484ba16c7cef

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module Datagrid

  # Required to be ActiveModel compatible
  # @private
  module ActiveModel #:nodoc:

    def self.included(base)
      base.extend         ClassMethods
      base.class_eval do
        begin
          require 'active_model/naming'
          extend ::ActiveModel::Naming
        rescue LoadError
        end
        begin
          require 'active_model/attributes_assignment'
          extend ::ActiveModel::AttributesAssignment
        rescue LoadError
        end

      end
      base.send :include, InstanceMethods
    end # self.included

    module ClassMethods
      def param_name
        self.to_s.underscore.tr('/', '_')
      end
    end # ClassMethods

    module InstanceMethods
      def param_name
        self.class.param_name
      end

      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
        self.param_name
      end
    end # InstanceMethods
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
datagrid-1.6.3 lib/datagrid/active_model.rb
datagrid-1.6.2 lib/datagrid/active_model.rb
datagrid-1.6.1 lib/datagrid/active_model.rb
datagrid-1.6.0 lib/datagrid/active_model.rb
datagrid-1.5.9 lib/datagrid/active_model.rb
datagrid-1.5.8 lib/datagrid/active_model.rb
datagrid-1.5.7 lib/datagrid/active_model.rb
datagrid-1.5.6 lib/datagrid/active_model.rb
datagrid-1.5.5 lib/datagrid/active_model.rb
datagrid-1.5.4 lib/datagrid/active_model.rb