Module: ContextExposer::BaseController::ClassMethods
- Defined in:
- lib/context_exposer/base_controller.rb
Instance Method Summary collapse
- #_exposure_storage ⇒ Object
- #base_item_actions ⇒ Object
- #base_list_actions ⇒ Object
- #context_expose(name, options = {}) ⇒ Object
- #expose_cached(name, options = {}, &block) ⇒ Object
- #exposed(name, options = {}, &block) ⇒ Object
- #integrate_with(*names) ⇒ Object (also: #integrates_with)
- #item_actions(*names) ⇒ Object
- #list_actions(*names) ⇒ Object
- #normalized_resource_name ⇒ Object
- #view_ctx_class(name) ⇒ Object
Instance Method Details
#_exposure_storage ⇒ Object
75 76 77 |
# File 'lib/context_exposer/base_controller.rb', line 75 def _exposure_storage _exposure_hash[self.to_s] ||= {} end |
#base_item_actions ⇒ Object
44 45 46 |
# File 'lib/context_exposer/base_controller.rb', line 44 def base_item_actions [:show, :new, :edit] end |
#base_list_actions ⇒ Object
40 41 42 |
# File 'lib/context_exposer/base_controller.rb', line 40 def base_list_actions [:index] end |
#context_expose(name, options = {}) ⇒ Object
71 72 73 |
# File 'lib/context_exposer/base_controller.rb', line 71 def context_expose name, = {} send "context_expose_#{name}", end |
#expose_cached(name, options = {}, &block) ⇒ Object
30 31 32 |
# File 'lib/context_exposer/base_controller.rb', line 30 def expose_cached name, = {}, &block exposed name, .merge(cached: true), &block end |
#exposed(name, options = {}, &block) ⇒ Object
26 27 28 |
# File 'lib/context_exposer/base_controller.rb', line 26 def exposed name, = {}, &block _exposure_storage[name.to_sym] = {options: , proc: block} end |
#integrate_with(*names) ⇒ Object Also known as: integrates_with
64 65 66 67 68 |
# File 'lib/context_exposer/base_controller.rb', line 64 def integrate_with *names names.flatten.compact.each do |name| self.send :include, "ContextExposer::Integrations::With#{name.to_s.camelize}".constantize end end |
#item_actions(*names) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/context_exposer/base_controller.rb', line 56 def item_actions *names return if names.blank? names = names.flatten.map(&:to_sym) (class << self; end).define_method :item_actions do names | base_item_actions end end |
#list_actions(*names) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/context_exposer/base_controller.rb', line 48 def list_actions *names return if names.blank? names = names.flatten.map(&:to_sym) (class << self; end).define_method :list_actions do names | base_list_actions end end |
#normalized_resource_name ⇒ Object
22 23 24 |
# File 'lib/context_exposer/base_controller.rb', line 22 def normalized_resource_name self.to_s.demodulize.sub(/Controller$/, '').underscore.singularize end |
#view_ctx_class(name) ⇒ Object
34 35 36 37 38 |
# File 'lib/context_exposer/base_controller.rb', line 34 def view_ctx_class name define_method :view_ctx_class do @view_ctx_class ||= name.kind_of?(Class) ? name : name.to_s.camelize.constantize end end |