Module: Card::Set::Abstract::Pointer::OptionsApi

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb,
card/tmpsets/set/mod008-card-mod-list/abstract/01_pointer/options_api.rb

Overview

Set: Abstract (Pointer, OptionsApi)

TODO: some of this should be moved to right/options!!

Defined Under Namespace

Modules: Format, HtmlFormat

Constant Summary

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_modules

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

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#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 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 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 8

def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-list/set/abstract/01_pointer/options_api.rb"; end

Instance Method Details

#json_options?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 15

def json_options?
  options_card&.type_id == JsonID
end

#option_cardsObject



33
34
35
36
37
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 33

def option_cards
  option_names.map do |name|
    Card.fetch name, new: {}
  end
end

#option_hash_from_namesObject



19
20
21
22
23
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 19

def option_hash_from_names
  option_names.each_with_object({}) do |name, hash|
    hash[name] = name
  end
end

#option_namesObject



25
26
27
28
29
30
31
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 25

def option_names
  if (selected_options = item_names)
    (standard_option_names + selected_options).uniq
  else
    standard_option_names
  end
end

#option_names_from_itemsObject



51
52
53
54
55
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 51

def option_names_from_items
  o_card = options_card
  limit = o_card.try(:default_limit).to_i
  o_card.item_names context: name, limit: limit
end

#options_cardObject



57
58
59
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 57

def options_card
  options_rule_card || Card[:all]
end

#options_card_nameObject



61
62
63
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 61

def options_card_name
  options_rule_card&.name&.url_key || ":all"
end

#options_hashObject

or to type/JSON?



11
12
13
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 11

def options_hash
  json_options? ? options_card.parse_content : option_hash_from_names
end

#options_rule_cardObject



39
40
41
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 39

def options_rule_card
  rule_card :content_options
end

#standard_option_namesObject



43
44
45
46
47
48
49
# File 'card/tmpsets/set/mod009-card-mod-list/abstract/01_pointer/options_api.rb', line 43

def standard_option_names
  if json_options?
    options_hash.values.map(&:to_name)
  else
    option_names_from_items
  end
end