Sha256: b8190a9ce8005f7653fff55bb9521f9440f8528efb247d054a2f765f37a8c3fe

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'pry' rescue nil
require 'core_ext/boolean'
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/hash/keys"
require 'active_support/cache'
require 'jsonapionify/autoload'

module JSONAPIonify
  autoload :VERSION, 'jsonapi-objects/version'
  extend JSONAPIonify::Autoload
  autoload_all 'jsonapionify'

  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

  def self.path
    __dir__
  end

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

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

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

  def self.digest
    @digest ||= Digest::SHA2.hexdigest(
      Dir.glob(File.join __dir__, '**/*.rb').map { |f| File.read f }.join
    )
  end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapionify-0.9.0 lib/jsonapionify.rb