Module: Card::Set::Type::Set::SettingCategories

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb

Overview

Set: All “Set+SettingCategories” cards (SettingCategories)

Constant Summary collapse

SETTING_OPTIONS =
[["Common", :common_rules],
["All", :all_rules],
["Field", :field_related_rules],
["Recent", :recent_rules]].freeze
COMMON_SETTINGS =
%i[create read update delete structure default guide].freeze
FIELD_SETTINGS =
%i[default help].freeze

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset

Methods included from I18nScope

#mod_name, #scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from AdvancedApi

#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #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 Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/mod/rules/set/type/set/setting_categories.rb"; end

Instance Method Details

#all_settingsObject



58
59
60
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 58

def all_settings
  visible_setting_codenames.sort
end

#categories(setting) ⇒ Object



16
17
18
19
20
21
22
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 16

def categories setting
  result = [:all]
  result += %i[field recent common].select do |cat|
    category_settings(cat)&.include? setting
  end
  result
end

#category_settings(cat) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 37

def category_settings cat
  case cat
  when :all, :all_rules
    all_settings
  when :recent, :recent_rules
    recent_settings
  when :common, :common_rules
    visible_setting_codenames & COMMON_SETTINGS
  when :field, :field_related, :field_related_rules
    field_related_settings
  when :nest_editor_field_related
    nest_editor_field_related_settings
  else
    group_settings cat
  end
end


67
68
69
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 67

def field_related_settings
  field_settings # card.visible_setting_codenames &
end

#field_settingsObject



28
29
30
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 28

def field_settings
  %i[default help input_type content_options content_option_view]
end

#group_settings(group) ⇒ Object



54
55
56
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 54

def group_settings group
  visible_settings(group).map(&:codename) if Card::Setting.groups[group]
end


62
63
64
65
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 62

def nest_editor_field_related_settings
  field_settings
  #  & card.visible_settings(nil, card.prototype_default_type_id).map(&:codename)
end

#recent_settingsObject



71
72
73
74
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 71

def recent_settings
  recent_settings = Card[:recent_settings].item_cards.map(&:codename).compact
  recent_settings & visible_setting_codenames
end

#selected_setting_category(default = :common) ⇒ Object



24
25
26
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 24

def selected_setting_category default=:common
  voo&.filter&.to_sym || params[:group]&.to_sym || default
end

#setting_list(val) ⇒ Object

Parameters:

  • val

    setting category, setting group or single setting



33
34
35
# File 'platypus/tmp/set/gem-defaults/mod010-rules/type/set/setting_categories.rb', line 33

def setting_list val
  category_settings(val) || group_settings(val) || [val]
end