Module: Card::Set::Abstract::AssetInputter

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb

Overview

Set: Abstract (AssetInputter)

Defined Under Namespace

Modules: 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

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 Card::Set::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 Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject

[View source]

7
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/mod/assets/set/abstract/asset_inputter.rb"; end

Instance Method Details

#assemble_asset_input_contentObject

[View source]

56
57
58
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 56

def assemble_asset_input_content
  format(input_format).render input_view
end

#asset_input_contentObject

[View source]

50
51
52
53
54
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 50

def asset_input_content
  return assemble_asset_input_content if virtual?
  update_asset_input if asset_input.blank?
  asset_input
end

#asset_input_needs_refresh?Boolean

Returns:

  • (Boolean)
[View source]

72
73
74
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 72

def asset_input_needs_refresh?
  false
end

#asset_input_updated_atObject

[View source]

64
65
66
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 64

def asset_input_updated_at
  asset_input_card&.updated_at
end

#asset_inputter?Boolean

for override

Returns:

  • (Boolean)
[View source]

77
78
79
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 77

def asset_inputter?
  true
end

#dependent_asset_inputtersObject

[View source]

10
11
12
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 10

def dependent_asset_inputters
  referers_responding_to :asset_input
end

#event: asset_input_changedObject

[View source]

22
23
24
25
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 22

event :asset_input_changed, :finalize,
      on: :save, when: :asset_inputter?, changed: :content, skip: :allowed do
  update_asset_input
end

#event: asset_input_changed_on_deleteObject

[View source]

27
28
29
30
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 27

event :asset_input_changed_on_delete, :finalize,
      on: :delete, when: :asset_inputter?, before: :clear_references do
  update_referers_after_input_changed
end

#input_viewObject

[View source]

60
61
62
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 60

def input_view
  :core
end

#outputtersObject

[View source]

14
15
16
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 14

def outputters
  referers_responding_to :update_asset_output
end

#referers_responding_to(method_name) ⇒ Object

[View source]

18
19
20
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 18

def referers_responding_to method_name
  referers.select { |referer| referer.respond_to? method_name }
end

#refresh_assetObject

[View source]

68
69
70
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 68

def refresh_asset
  update_asset_input if asset_input_needs_refresh?
end

#update_asset_inputObject

[View source]

40
41
42
43
44
45
46
47
48
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 40

def update_asset_input
  return unless Codename.exist? :asset_input
  # otherwise the migration that adds the asset_input card fails

  Card::Auth.as_bot do
    asset_input_card.update({})
    update_referers_after_input_changed
  end
end

#update_referers_after_input_changedObject

[View source]

32
33
34
35
36
37
38
# File 'platypus/tmp/set/gem-defaults/mod018-assets/abstract/asset_inputter.rb', line 32

def update_referers_after_input_changed
  # puts "dependent inputters for #{name}: #{dependent_asset_inputters}"
  # puts "outputters: #{outputters}"

  dependent_asset_inputters.each(&:update_asset_input)
  outputters.each(&:update_asset_output)
end