Sha256: 88e22b76b9501d1307f551be55cee8e276cf680c659cc472f3bbd9fd5e6c4051

Contents?: true

Size: 904 Bytes

Versions: 24

Compression:

Stored size: 904 Bytes

Contents

module Datagrid

  # Required to be ActiveModel compatible
  module ActiveModel
  
    def self.included(base)
      base.extend         ClassMethods
      base.class_eval do
        begin
          require 'active_model/naming'
          extend ::ActiveModel::Naming
        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

24 entries across 24 versions & 1 rubygems

Version Path
datagrid-1.1.2 lib/datagrid/active_model.rb
datagrid-1.1.1 lib/datagrid/active_model.rb
datagrid-1.1.0 lib/datagrid/active_model.rb
datagrid-1.0.5 lib/datagrid/active_model.rb
datagrid-1.0.4 lib/datagrid/active_model.rb
datagrid-1.0.3 lib/datagrid/active_model.rb
datagrid-1.0.2 lib/datagrid/active_model.rb
datagrid-1.0.1 lib/datagrid/active_model.rb
datagrid-1.0.0 lib/datagrid/active_model.rb
datagrid-0.9.3 lib/datagrid/active_model.rb
datagrid-0.9.2 lib/datagrid/active_model.rb
datagrid-0.9.0 lib/datagrid/active_model.rb
datagrid-0.8.4 lib/datagrid/active_model.rb
datagrid-0.8.3 lib/datagrid/active_model.rb
datagrid-0.8.2 lib/datagrid/active_model.rb
datagrid-0.8.1 lib/datagrid/active_model.rb
datagrid-0.8.0 lib/datagrid/active_model.rb
datagrid-0.7.1 lib/datagrid/active_model.rb
datagrid-0.7.0 lib/datagrid/active_model.rb
datagrid-0.6.4 lib/datagrid/active_model.rb