Module: Card::Set::Type::Json
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod004-format/type/json.rb
Overview
Set: All “Json” cards
Defined Under Namespace
Modules: HtmlFormat
Constant Summary
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included from Event::Api
Class Method Summary collapse
Instance Method Summary collapse
-
#check_json_syntax ⇒ Object
-
#event: validate_json ⇒ Object
-
#item_names(_args = {}) ⇒ Object
-
#item_value(name) ⇒ Object
-
#item_values ⇒ Object
-
#parse_content ⇒ Object
Methods included from Card::Set
Methods included from I18nScope
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
Class Method Details
.source_location ⇒ Object
7 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 7 def self.source_location; "/Users/ethan/dev/decko/gem/mod/format/set/type/json.rb"; end |
Instance Method Details
#check_json_syntax ⇒ Object
14 15 16 17 18 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 14 def check_json_syntax parse_content rescue JSON::ParserError => e errors.add t(:format_invalid_json), e..sub(/^\d+: /, "").to_s end |
#event: validate_json ⇒ Object
10 11 12 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 10 event :validate_json, :validate, on: :save, changed: :content do check_json_syntax if content.present? end |
#item_names(_args = {}) ⇒ Object
24 25 26 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 24 def item_names _args={} parse_content.keys.map(&:to_name) end |
#item_value(name) ⇒ Object
32 33 34 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 32 def item_value name parse_content[name] end |
#item_values ⇒ Object
28 29 30 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 28 def item_values parse_content.values end |
#parse_content ⇒ Object
20 21 22 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/type/json.rb', line 20 def parse_content content.blank? ? "" : JSON.parse(content) end |