Module: JSONAPIonify

Extended by:
Autoload
Defined in:
lib/jsonapionify.rb,
lib/jsonapionify/version.rb,
lib/jsonapionify/autoload.rb,
lib/jsonapionify/callbacks.rb,
lib/jsonapionify/structure.rb,
lib/jsonapionify/continuation.rb,
lib/jsonapionify/documentation.rb,
lib/jsonapionify/api/test_helper.rb,
lib/jsonapionify/character_range.rb,
lib/jsonapionify/indented_string.rb,
lib/jsonapionify/api/errors_object.rb,
lib/jsonapionify/deep_sort_collection.rb,
lib/jsonapionify/inherited_attributes.rb

Defined Under Namespace

Modules: Api, Autoload, Callbacks, DeepSortCollection, DestructuredProc, IndentedString, InheritedAttributes, Structure, Types Classes: CharacterRange, Continuation, CustomRescue, Documentation

Constant Summary collapse

TRUTHY_STRINGS =
%w(t true y yes 1).flat_map do |str|
  [str.downcase, str.upcase, str.capitalize]
end.uniq
FALSEY_STRINGS =
%w(f false n no 0).flat_map do |str|
  [str.downcase, str.upcase, str.capitalize]
end.uniq
VERSION =
"0.12.8"

Class Method Summary collapse

Methods included from Autoload

autoload_all, eager_load!, unloaded

Class Method Details

.cache(store, *args) ⇒ Object



35
36
37
# File 'lib/jsonapionify.rb', line 35

def self.cache(store, *args)
  self.cache_store = ActiveSupport::Cache.lookup_store(store, *args)
end

.cache_storeObject



90
91
92
# File 'lib/jsonapionify.rb', line 90

def self.cache_store
  @cache_store ||= ActiveSupport::Cache.lookup_store :null_store
end

.cache_store=(store) ⇒ Object



78
79
80
# File 'lib/jsonapionify.rb', line 78

def self.cache_store=(store)
  @cache_store = store
end

.digestObject



43
44
45
46
47
48
49
50
# File 'lib/jsonapionify.rb', line 43

def self.digest
  @digest ||=
    files.map do |f|
      File.read f
    end.reduce(
      Digest::SHA2.new, :update
    ).to_s
end

.disable_validation(bool) ⇒ Object



82
83
84
# File 'lib/jsonapionify.rb', line 82

def self.disable_validation(bool)
  @validation_disabled = bool
end

.filesObject



39
40
41
# File 'lib/jsonapionify.rb', line 39

def self.files
  Dir.glob(File.join __dir__, './**/*.rb').map { |f| File.expand_path f }.sort
end

.loggerObject



74
75
76
# File 'lib/jsonapionify.rb', line 74

def self.logger
  @logger ||= defined?(Rails) ? Rails.logger : Logger.new('/dev/null')
end

.logger=(logger) ⇒ Object



70
71
72
# File 'lib/jsonapionify.rb', line 70

def self.logger=(logger)
  @logger = logger
end

.new_object(*args) ⇒ Object



31
32
33
# File 'lib/jsonapionify.rb', line 31

def self.new_object(*args)
  Structure::Objects::TopLevel.new(*args)
end

.parse(hash) ⇒ Object



26
27
28
29
# File 'lib/jsonapionify.rb', line 26

def self.parse(hash)
  hash = Oj.load(hash) if hash.is_a? String
  Structure::Objects::TopLevel.from_hash(hash)
end

.pathObject



22
23
24
# File 'lib/jsonapionify.rb', line 22

def self.path
  __dir__
end

.show_backtraceObject



65
66
67
68
# File 'lib/jsonapionify.rb', line 65

def self.show_backtrace
  return @show_backtrace if instance_variable_defined?(:@show_backtrace)
  self.show_backtrace = ENV['RACK_ENV'] != 'production'
end

.show_backtrace=(value) ⇒ Object



61
62
63
# File 'lib/jsonapionify.rb', line 61

def self.show_backtrace=(value)
  @show_backtrace = value
end

.validation_disabled?Boolean

Returns:



86
87
88
# File 'lib/jsonapionify.rb', line 86

def self.validation_disabled?
  !!@validation_disabled
end

.verbose_errorsObject



56
57
58
59
# File 'lib/jsonapionify.rb', line 56

def self.verbose_errors
  return @verbose_errors if instance_variable_defined?(:@verbose_errors)
  self.verbose_errors = ENV['RACK_ENV'] != 'production'
end

.verbose_errors=(value) ⇒ Object



52
53
54
# File 'lib/jsonapionify.rb', line 52

def self.verbose_errors=(value)
  self.show_backtrace = @verbose_errors = value
end