class DestroyAllViewAssigns::DataCollector

Attributes

controller[R]

Public Class Methods

new(controller) click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 5
def initialize(controller)
  @controller = controller
end

Public Instance Methods

add(variable_name) click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 9
def add(variable_name)
  action_data[:vars] << variable_name
  controller_data[:vars] << variable_name
end
collect!() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 14
def collect!
  controller_data[:actions][action_name] = action_data

  CollectedData.transaction  do
    CollectedData[klass] = controller_data
  end
end

Private Instance Methods

action_data() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 54
def action_data
  @action_data ||= (get_action_data || default_action_data)
end
action_name() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 66
def action_name
  controller.action_name
end
controller_data() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 39
def controller_data
  @controller_data ||= (get_controller_data || default_controller_data)
end
controller_name() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 62
def controller_name
  controller.controller_name
end
default_action_data() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 47
def default_action_data
  {
    name: action_name,
    vars: Set.new
  }
end
default_controller_data() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 30
def default_controller_data
  {
    controller_name: controller_name,
    klass: klass,
    vars: Set.new,
    actions: {}
  }
end
get_action_data() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 43
def get_action_data
  controller_data[:actions][action_name]
end
get_controller_data() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 24
def get_controller_data
  CollectedData.transaction  do
    CollectedData[klass]
  end
end
klass() click to toggle source
# File lib/destroy_all_view_assigns/data_collector.rb, line 58
def klass
  controller.class.to_s
end