Module: Adva::Markup::ActionController::InstanceMethods

Defined in:
lib/adva/markup/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#render(*args) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/adva/markup/action_controller.rb', line 19

def render(*args)
  options  = filtered_attribute_options
  excluded = options[:except].include?(params[:action].to_sym)
  included = options[:only].empty? || options[:only].include?(params[:action].to_sym)

  !excluded && included ? with_filtered_attributes { super } : super
end

#with_filtered_attributesObject



27
28
29
30
31
32
33
# File 'lib/adva/markup/action_controller.rb', line 27

def with_filtered_attributes
  models = filtered_attribute_options[:models].map(&:constantize)
  models.each { |model| model.read_filtered_attributes = true }
  yield.tap do
    models.each { |model| model.read_filtered_attributes = false }
  end
end