Module: ReSorcery

Extended by:
Configuration
Includes:
Fielded, Helpers, Linked
Defined in:
lib/re_sorcery.rb,
lib/re_sorcery/error.rb,
lib/re_sorcery/maybe.rb,
lib/re_sorcery/linked.rb,
lib/re_sorcery/result.rb,
lib/re_sorcery/decoder.rb,
lib/re_sorcery/fielded.rb,
lib/re_sorcery/helpers.rb,
lib/re_sorcery/version.rb,
lib/re_sorcery/arg_check.rb,
lib/re_sorcery/result/ok.rb,
lib/re_sorcery/maybe/just.rb,
lib/re_sorcery/result/err.rb,
lib/re_sorcery/configuration.rb,
lib/re_sorcery/maybe/nothing.rb,
lib/re_sorcery/decoder/builtin_decoders.rb,
lib/re_sorcery/linked/link_class_factory.rb,
lib/re_sorcery/fielded/expand_internal_fields.rb

Defined Under Namespace

Modules: Configuration, Error, Fielded, Helpers, Linked, Maybe, Result Classes: Decoder

Constant Summary collapse

VERSION =
"0.3.0"

Constants included from Configuration

Configuration::CONFIGURABLES, Configuration::DEFAULT_LINK_METHOD_DECODER, Configuration::UNIQUE_STRING_OR_SYMBOL

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Configuration

configuration, configure

Methods included from Linked

link_class, #links

Methods included from Fielded

#fields

Class Method Details

.included(base) ⇒ Object



22
23
24
25
26
# File 'lib/re_sorcery.rb', line 22

def self.included(base)
  base.extend Fielded::ClassMethods
  base.extend Linked::ClassMethods
  @configured = "included at #{caller_locations.first}"
end

Instance Method Details

#as_jsonObject



34
35
36
37
38
39
# File 'lib/re_sorcery.rb', line 34

def as_json(*)
  resource.cata(
    ok: ->(r) { r },
    err: ->(e) { raise Error::InvalidResourceError, e },
  )
end

#resourceObject



28
29
30
31
32
# File 'lib/re_sorcery.rb', line 28

def resource
  Result::Ok.new({})
    .assign(:payload) { fields }
    .assign(:links) { links }
end