Module: Gridify::ClassMethods

Defined in:
lib/jquery/gridify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gridsObject

Returns the value of attribute grids.



10
11
12
# File 'lib/jquery/gridify.rb', line 10

def grids
  @grids
end

Instance Method Details

#grid(name = nil) ⇒ Object



33
34
35
# File 'lib/jquery/gridify.rb', line 33

def grid(name=nil)
  name ? grids[name] : grids[:grid]
end

#gridify(*args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jquery/gridify.rb', line 12

def gridify(*args, &block)
  # debugger
  grid = Gridify::Grid.new(self, *args, &block)
  @grids ||= {}
  @grids[grid.name.to_sym] = grid

  unless self.respond_to?(:find_for_grid)
    class_eval <<-EOV
		named_scope :find_for_grid, lambda {|name, params|
			grid = grids[name]
			grid.update_from_params( params )
			grid.current_scope
		}
    EOV
  end
end