Class: SmartListing::Configuration
- Inherits:
-
Object
- Object
- SmartListing::Configuration
- Defined in:
- lib/smart_listing/config.rb
Constant Summary collapse
- DEFAULT_PAGE_SIZES =
[10, 20, 50, 100]
- DEFAULTS =
{ :global_options => { :param_names => { # param names :page => :page, :per_page => :per_page, :sort => :sort, }, :array => false, # controls whether smart list should be using arrays or AR collections :max_count => nil, # limit number of rows :unlimited_per_page => false, # allow infinite page size :paginate => true, # allow pagination :memorize_per_page => false, :page_sizes => DEFAULT_PAGE_SIZES, # set available page sizes array :kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options }, :constants => { :classes => { :main => "smart-listing", :editable => "editable", :content => "content", :loading => "loading", :status => "smart-listing-status", :item_actions => "actions", :new_item_placeholder => "new-item-placeholder", :new_item_action => "new-item-action", :new_item_button => "btn", :hidden => "hidden", :autoselect => "autoselect", :callback => "callback", :pagination_per_page => "pagination-per-page text-center", :pagination_count => "count", :inline_editing => "info", :no_records => "no-records", :limit => "smart-listing-limit", :limit_alert => "smart-listing-limit-alert", :controls => "smart-listing-controls", :controls_reset => "reset", :filtering => "filter", :filtering_search => "glyphicon-search", :filtering_cancel => "glyphicon-remove", :filtering_disabled => "disabled", :sortable => "sortable", :icon_new => "glyphicon glyphicon-plus", :icon_edit => "glyphicon glyphicon-pencil", :icon_trash => "glyphicon glyphicon-trash", :icon_inactive => "glyphicon glyphicon-remove-circle text-muted", :icon_show => "glyphicon glyphicon-share-alt", :icon_sort_none => "glyphicon glyphicon-resize-vertical", :icon_sort_up => "glyphicon glyphicon-chevron-up", :icon_sort_down => "glyphicon glyphicon-chevron-down", :muted => "text-muted", }, :data_attributes => { :main => "smart-listing", :confirmation => "confirmation", :id => "id", :href => "href", :callback_href => "callback-href", :max_count => "max-count", :inline_edit_backup => "smart-listing-edit-backup", :params => "params", :observed => "observed", :href => "href", :autoshow => "autoshow", :popover => "slpopover", }, :selectors => { :item_action_destroy => "a.destroy", :edit_cancel => "button.cancel", :row => "tr", :head => "thead", :filtering_button => "button", :filtering_icon => "button span", :filtering_input => ".filter input" } } }
Instance Method Summary collapse
- #classes(key) ⇒ Object
- #constants(key, value = nil) ⇒ Object
- #data_attributes(key) ⇒ Object
- #global_options(value = nil) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(sym, *args, &block) ⇒ Object
- #selectors(key) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
95 96 97 |
# File 'lib/smart_listing/config.rb', line 95 def initialize @options = DEFAULTS end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
99 100 101 |
# File 'lib/smart_listing/config.rb', line 99 def method_missing(sym, *args, &block) @options[sym] = *args end |
Instance Method Details
#classes(key) ⇒ Object
110 111 112 |
# File 'lib/smart_listing/config.rb', line 110 def classes key @options[:constants][:classes][key] end |
#constants(key, value = nil) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/smart_listing/config.rb', line 103 def constants key, value = nil if value @options[:constants][key].merge!(value) end @options[:constants][key] end |
#data_attributes(key) ⇒ Object
114 115 116 |
# File 'lib/smart_listing/config.rb', line 114 def data_attributes key @options[:constants][:data_attributes][key] end |
#global_options(value = nil) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/smart_listing/config.rb', line 122 def value = nil if value @options[:global_options].merge!(value) end @options[:global_options] end |
#selectors(key) ⇒ Object
118 119 120 |
# File 'lib/smart_listing/config.rb', line 118 def selectors key @options[:constants][:selectors][key] end |