Sha256: dcb3af2471227b3ab39365539a794203b6ba7b3b643c7a1aea29afd68cb10857

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

require 'jqgrid_rails/jqgrid_rails_structure'

module JqGridRails
  # JqGridStructureRegistry is a module that, once included, adds some class methods to enable
  # registering and fetching of grid structures by the grid's name
  # see examples/usage.rb file for more details
  module StructureRegistry

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      # Creates a new GridStructure object and stores it in a slot with grid_name as key 
      # grid_name:: grid name symbol (first arg of JqGrid.new(...))
      def register_grid(grid_name)
        @grids ||= {}
        @grids[grid_name.to_sym] = JqGridRails::Structure.new(self, grid_name)
      end

      # Fetches grid from grid_name symbol
      def get_grid(grid_name)
        @grids[grid_name.to_sym]
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jqgrid_rails-1.2.4 lib/jqgrid_rails/jqgrid_rails_structure_registry.rb