Class: SmartListing::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_listing/config.rb

Constant Summary collapse

DEFAULTS =
{
  :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",
      :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-circle",
      :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",
    },
    :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",
    },
    :selectors => {
      :item_action_destroy => "a.destroy",
      :edit_cancel => "button.cancel",
      :row => "tr",
      :head => "thead",
      :filtering_icon => "i"
    }
  }
}

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



71
72
73
# File 'lib/smart_listing/config.rb', line 71

def initialize
  @options = DEFAULTS
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



75
76
77
# File 'lib/smart_listing/config.rb', line 75

def method_missing(sym, *args, &block)
  @options[sym] = *args
end

Instance Method Details

#classes(key) ⇒ Object



87
88
89
# File 'lib/smart_listing/config.rb', line 87

def classes key
  @options[:constants][:classes][key]
end

#constants(key, value = nil) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/smart_listing/config.rb', line 79

def constants key, value = nil
  if value == nil
    @options[:constants][key]
  else
    @options[:constants][key].merge!(value)
  end
end

#data_attributes(key) ⇒ Object



91
92
93
# File 'lib/smart_listing/config.rb', line 91

def data_attributes key
  @options[:constants][:data_attributes][key]
end

#selectors(key) ⇒ Object



95
96
97
# File 'lib/smart_listing/config.rb', line 95

def selectors key
  @options[:constants][:selectors][key]
end