Class: Azeroth::Options Private

Inherits:
Sinclair::Options
  • Object
show all
Defined in:
lib/azeroth/options.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Resource buiilding options

See Also:

Author:

  • Darthjee

Constant Summary collapse

DEFAULT_OPTIONS =

Default options

{
  only: i[create destroy edit index new show update],
  except: [],
  decorator: true,
  before_save: nil,
  after_save: nil,
  build_with: nil,
  paginated: false,
  per_page: 20
}.freeze

Instance Method Summary collapse

Instance Method Details

#actionsArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Actions to be built

Returns:

  • (Array<Symbol>)


33
34
35
# File 'lib/azeroth/options.rb', line 33

def actions
  [only].flatten.map(&:to_sym) - [except].flatten.map(&:to_sym)
end

#after_saveSymbol, Proc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Block or method name to be run after save

The given method or block will be ran after committing changes in models to database

Returns:

  • (Symbol, Proc)


# File 'lib/azeroth/options.rb', line 95


#before_saveSymbol, Proc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Block or method name to be run before save

The given method or block will be ran before committing changes in models to database

Returns:

  • (Symbol, Proc)


# File 'lib/azeroth/options.rb', line 84


#build_withSymbol, Proc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Block or method name to be ran when building the resource

Returns:

  • (Symbol, Proc)


# File 'lib/azeroth/options.rb', line 106


#decoratorDecorator, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

decorator class to be used

when set as true/false, it either infer the class (model_class::Decorator) or do not use a decorator at all calling model.as_json

Returns:



# File 'lib/azeroth/options.rb', line 72


#event_dispatcher(event) ⇒ Jace::Dispatcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns event dispatcher

Event dispatcher is responsible for sending events such as before_save to it’s correct calling point

Returns:

  • (Jace::Dispatcher)


44
45
46
47
48
49
# File 'lib/azeroth/options.rb', line 44

def event_dispatcher(event)
  Jace::Dispatcher.new(
    before: try("before_#{event}"),
    after: try("after_#{event}")
  )
end

#exceptArray<String,Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

actions to be ignored

Returns:

  • (Array<String,Symbol>)


# File 'lib/azeroth/options.rb', line 65


#onlyArray<String,Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

filter of only actions to be built

Returns:

  • (Array<String,Symbol>)


# File 'lib/azeroth/options.rb', line 58


#paginatedTrueClass, FalseClass Also known as: paginated?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Boolean indicating if pagination should or not be used

Returns:

  • (TrueClass, FalseClass)


# File 'lib/azeroth/options.rb', line 113


#per_pageInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Number of elements when pagination is active

Returns:

  • (Integer)


# File 'lib/azeroth/options.rb', line 120