Class: Tableficate::Base
- Inherits:
-
Object
- Object
- Tableficate::Base
- Extended by:
- Finder
- Defined in:
- lib/tableficate/base.rb
Class Method Summary collapse
- .column(name, options = {}) ⇒ Object
- .default_sort(name, dir = 'asc') ⇒ Object
- .filter(name, options = {}, &block) ⇒ Object
- .scope(model = nil) ⇒ Object
Methods included from Finder
Class Method Details
.column(name, options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/tableficate/base.rb', line 17 def self.column(name, = {}) @sort ||= {} @sort[name] = [:sort] if [:sort].present? end |
.default_sort(name, dir = 'asc') ⇒ Object
13 14 15 |
# File 'lib/tableficate/base.rb', line 13 def self.default_sort(name, dir = 'asc') @default_sort = [name, dir] end |
.filter(name, options = {}, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tableficate/base.rb', line 23 def self.filter(name, = {}, &block) @filter ||= {} if block_given? @filter[name] = block else .reverse_merge!( field: name ) @filter[name] = end end |
.scope(model = nil) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/tableficate/base.rb', line 5 def self.scope(model = nil) if block_given? @scope = yield else @scope = model.to_s.camelize.constantize end end |