Module: HyperKittenTables::Concerns::Table
- Extended by:
- ActiveSupport::Concern
- Included in:
- HyperKittenTables::Components::Table
- Defined in:
- lib/hyper_kitten_tables/concerns/table.rb
Instance Method Summary collapse
- #define_header_sort_url(&block) ⇒ Object
- #footer(&block) ⇒ Object
- #header_sort_url(column, query_params) ⇒ Object
- #initialize(collection: [], requested_columns: []) {|_self| ... } ⇒ Object
- #render_in(view_context) ⇒ Object
- #table(**options) ⇒ Object
- #tbody(**options) ⇒ Object
- #td(name, method_name: nil, sort_key: nil, sortable: true, **options, &block) ⇒ Object
- #th(**options) ⇒ Object
- #thead(**options) ⇒ Object
- #tr(**options) ⇒ Object
Instance Method Details
#define_header_sort_url(&block) ⇒ Object
40 41 42 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 40 def define_header_sort_url(&block) define_singleton_method(:header_sort_url, &block) end |
#footer(&block) ⇒ Object
50 51 52 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 50 def (&block) = block end |
#header_sort_url(column, query_params) ⇒ Object
44 45 46 47 48 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 44 def header_sort_url(column, query_params) # Override this method to define the sort url for the header. raise NotImplementedError, "You must define #header_sort_url if you want sortable table columns." end |
#initialize(collection: [], requested_columns: []) {|_self| ... } ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 17 def initialize(collection: [], requested_columns: [], &block) @collection = collection @columns = [] = {} = {} = {} = {} = {} @requested_columns = requested_columns yield self if block_given? end |
#render_in(view_context) ⇒ Object
74 75 76 77 78 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 74 def render_in(view_context) @view_context = view_context render_table end |
#table(**options) ⇒ Object
54 55 56 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 54 def table(**) = end |
#tbody(**options) ⇒ Object
58 59 60 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 58 def tbody(**) = end |
#td(name, method_name: nil, sort_key: nil, sortable: true, **options, &block) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 31 def td(name, method_name: nil, sort_key: nil, sortable: true, **, &block) if method_name.nil? method_name = name.to_s.parameterize.underscore name = name.to_s.titleize unless block_given? end sort_key = method_name if sort_key.blank? @columns << Column.new(name, method_name, sort_key, block, sortable, ) end |
#th(**options) ⇒ Object
70 71 72 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 70 def th(**) = end |
#thead(**options) ⇒ Object
62 63 64 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 62 def thead(**) = end |
#tr(**options) ⇒ Object
66 67 68 |
# File 'lib/hyper_kitten_tables/concerns/table.rb', line 66 def tr(**) = end |