Module: Card::Set::Self::Admin

Extended by:
Card::Set
Defined in:
tmpsets/set/mod002-admin/self/admin.rb,
tmpsets/set/mod019-carrierwave/self/admin.rb

Overview

Set: The card "Admin"

Defined Under Namespace

Modules: HtmlFormat

Class Method Summary collapse

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



8
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 8

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/admin/set/self/admin.rb"; end

Instance Method Details

#current_memory_usageObject



138
139
140
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 138

def current_memory_usage
  `ps -o rss= -p #{Process.pid}`.to_i
end

#irreversibles_tasks_allowed?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 47

def irreversibles_tasks_allowed?
  Cardio.config.allow_irreversible_admin_tasks
end

#not_allowed(task) ⇒ Object



41
42
43
44
45
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 41

def not_allowed task
  raise Card::Error::PermissionDenied,
        "The admin task '#{task}' is disabled for security reasons.<br>"\
        "You can enable it with the config option 'allow_irreversible_admin_tasks'"
end

#profile_memory(&block) ⇒ Object



142
143
144
145
146
147
148
149
150
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 142

def profile_memory &block
  before = current_memory_usage
  if block_given?
    instance_eval(&block)
  else
    before = 0
  end
  (current_memory_usage - before) / 1024.to_i
end

#run_task_from_task_basket(task) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'tmpsets/set/mod002-admin/self/admin.rb', line 12

def run_task_from_task_basket task
  task = task.to_sym
  task_data = tasks.find {|h| h[:name].to_sym == task.to_sym}
  if !irreversibles_tasks_allowed? && task_data[:irreversible]
    not_allowed task_data[:stats][:link_text]
  else
    task_data[:execute_policy].call if task_data
  end
end