Module: ProxES::Helpers::Component
- Includes:
- ActiveSupport::Inflector
- Defined in:
- lib/proxes/helpers/component.rb
Instance Method Summary collapse
- #base_path ⇒ Object
- #dataset ⇒ Object
- #dehumanized ⇒ Object
- #heading(action = nil) ⇒ Object
- #list ⇒ Object
- #view_location ⇒ Object
Instance Method Details
#base_path ⇒ Object
38 39 40 |
# File 'lib/proxes/helpers/component.rb', line 38 def base_path settings.base_path || "/_proxes/#{dasherize(view_location)}" end |
#dataset ⇒ Object
11 12 13 |
# File 'lib/proxes/helpers/component.rb', line 11 def dataset policy_scope(settings.model_class) end |
#dehumanized ⇒ Object
34 35 36 |
# File 'lib/proxes/helpers/component.rb', line 34 def dehumanized settings.dehumanized || underscore(heading) end |
#heading(action = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/proxes/helpers/component.rb', line 22 def heading(action = nil) @headings ||= begin heading = titleize(demodulize(settings.model_class)) h = Hash.new(heading) h[:new] = "New #{heading}" h[:list] = pluralize heading h[:edit] = "Edit #{heading}" h end @headings[action] end |
#list ⇒ Object
15 16 17 18 19 20 |
# File 'lib/proxes/helpers/component.rb', line 15 def list params['count'] ||= 10 params['page'] ||= 1 dataset.select.paginate(params['page'].to_i, params['count'].to_i) end |
#view_location ⇒ Object
42 43 44 45 46 47 |
# File 'lib/proxes/helpers/component.rb', line 42 def view_location p settings.model_class p 'asd' p settings.view_location settings.view_location || underscore(pluralize(demodulize(settings.model_class))) end |