Module: Listings::ConfigurationMethods::ClassMethods
- Defined in:
- lib/listings/configuration_methods.rb
Instance Attribute Summary collapse
-
#page_size ⇒ Object
Returns the value of attribute page_size.
-
#row_style_applicator ⇒ Object
readonly
Returns the value of attribute row_style_applicator.
-
#sortable_options ⇒ Object
readonly
Returns the value of attribute sortable_options.
-
#table_css_class ⇒ Object
Returns the value of attribute table_css_class.
Instance Method Summary collapse
- #column(path = '', props = {}, &proc) ⇒ Object
- #columns ⇒ Object
- #css_class(value) ⇒ Object
- #custom_filter(key, props = {}, &proc) ⇒ Object
- #deferred_scopes(&block) ⇒ Object
- #export(*formats) ⇒ Object
- #export_formats ⇒ Object
- #filter(path = '', props = {}, &proc) ⇒ Object
- #filters ⇒ Object
- #fix_path_props(path, props) ⇒ Object
- #layout(props = {}) ⇒ Object
- #layout_options ⇒ Object
- #model(model_class = nil, &proc) ⇒ Object
- #paginates_per(val) ⇒ Object
- #process_scopes ⇒ Object
- #row_style(&proc) ⇒ Object
- #scope(*args, &block) ⇒ Object
- #scopes ⇒ Object
-
#selectable ⇒ Object
(column = :id).
- #selectable? ⇒ Boolean
-
#sortable(*options) ⇒ Object
call ‘sortable false` make listing non sorted default is `sortable true`.
Instance Attribute Details
#page_size ⇒ Object
Returns the value of attribute page_size.
68 69 70 |
# File 'lib/listings/configuration_methods.rb', line 68 def page_size @page_size end |
#row_style_applicator ⇒ Object (readonly)
Returns the value of attribute row_style_applicator.
71 72 73 |
# File 'lib/listings/configuration_methods.rb', line 71 def row_style_applicator @row_style_applicator end |
#sortable_options ⇒ Object (readonly)
Returns the value of attribute sortable_options.
69 70 71 |
# File 'lib/listings/configuration_methods.rb', line 69 def @sortable_options end |
#table_css_class ⇒ Object
Returns the value of attribute table_css_class.
70 71 72 |
# File 'lib/listings/configuration_methods.rb', line 70 def table_css_class @table_css_class end |
Instance Method Details
#column(path = '', props = {}, &proc) ⇒ Object
110 111 112 113 |
# File 'lib/listings/configuration_methods.rb', line 110 def column(path = '', props = {}, &proc) path, props = fix_path_props(path, props) columns << ColumnDescriptor.new(path, props, proc) end |
#columns ⇒ Object
106 107 108 |
# File 'lib/listings/configuration_methods.rb', line 106 def columns @columns ||= [] end |
#css_class(value) ⇒ Object
150 151 152 |
# File 'lib/listings/configuration_methods.rb', line 150 def css_class(value) @table_css_class = value end |
#custom_filter(key, props = {}, &proc) ⇒ Object
167 168 169 |
# File 'lib/listings/configuration_methods.rb', line 167 def custom_filter(key, props = {}, &proc) filters << CustomFilterDescriptor.new(key, props, proc) end |
#deferred_scopes(&block) ⇒ Object
85 86 87 |
# File 'lib/listings/configuration_methods.rb', line 85 def deferred_scopes(&block) scopes << DeferredScopeDescriptor.new(&block) end |
#export(*formats) ⇒ Object
138 139 140 141 142 |
# File 'lib/listings/configuration_methods.rb', line 138 def export(*formats) formats.each do |f| export_formats << f end end |
#export_formats ⇒ Object
134 135 136 |
# File 'lib/listings/configuration_methods.rb', line 134 def export_formats @export ||= [] end |
#filter(path = '', props = {}, &proc) ⇒ Object
162 163 164 165 |
# File 'lib/listings/configuration_methods.rb', line 162 def filter(path = '', props = {}, &proc) path, props = fix_path_props(path, props) filters << FilterDescriptor.new(path, props, proc) end |
#filters ⇒ Object
158 159 160 |
# File 'lib/listings/configuration_methods.rb', line 158 def filters @filters ||= [] end |
#fix_path_props(path, props) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/listings/configuration_methods.rb', line 115 def fix_path_props(path, props) if path.is_a?(Hash) && path.size > 1 props = props.merge(path) path = Hash[[path.first]] props.except!(path.first.first) end [path, props] end |
#layout(props = {}) ⇒ Object
171 172 173 |
# File 'lib/listings/configuration_methods.rb', line 171 def layout(props = {}) @layout_options = props end |
#layout_options ⇒ Object
175 176 177 |
# File 'lib/listings/configuration_methods.rb', line 175 def (@layout_options || {}).reverse_merge! filters: :side end |
#model(model_class = nil, &proc) ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/listings/configuration_methods.rb', line 96 def model(model_class = nil, &proc) if !model_class.nil? self.send(:define_method, 'model_class') do model_class end else self.send(:define_method, 'model_class', &proc) end end |
#paginates_per(val) ⇒ Object
73 74 75 |
# File 'lib/listings/configuration_methods.rb', line 73 def paginates_per(val) @page_size = val end |
#process_scopes ⇒ Object
89 90 91 92 93 94 |
# File 'lib/listings/configuration_methods.rb', line 89 def process_scopes scopes.each do |scope| scope.construct if scope.deferred? end @scopes = scopes.select{ |s| !s.deferred? } end |
#row_style(&proc) ⇒ Object
154 155 156 |
# File 'lib/listings/configuration_methods.rb', line 154 def row_style(&proc) @row_style_applicator = proc end |
#scope(*args, &block) ⇒ Object
77 78 79 |
# File 'lib/listings/configuration_methods.rb', line 77 def scope(*args, &block) scopes << ScopeDescriptor.new(*args, &block) end |
#scopes ⇒ Object
81 82 83 |
# File 'lib/listings/configuration_methods.rb', line 81 def scopes @scopes ||= [] end |
#selectable ⇒ Object
(column = :id)
125 126 127 128 |
# File 'lib/listings/configuration_methods.rb', line 125 def selectable #(column = :id) @selectable = true # @column_identifier = column end |
#selectable? ⇒ Boolean
130 131 132 |
# File 'lib/listings/configuration_methods.rb', line 130 def selectable? @selectable == true end |
#sortable(*options) ⇒ Object
call ‘sortable false` make listing non sorted default is `sortable true`
146 147 148 |
# File 'lib/listings/configuration_methods.rb', line 146 def sortable(*) @sortable_options = end |