class Preloadable::PreloadableAttributeConfig

Attributes

attrs[W]
defaults[W]

Public Instance Methods

add(*args) click to toggle source
# File lib/jsonapi-preloadable.rb, line 17
def add(*args)
  if args.size == 1
    # plain declaration
    # config.add relationship: :nested
    options = args.first
    attrs[options.keys.first] = options
  else
    # aliased declaration
    # config.add :alias, relationship: :nested
    key, value = args
    attrs[key] = value
  end
end
attrs() click to toggle source
# File lib/jsonapi-preloadable.rb, line 9
def attrs
  @attrs ||= {}
end
defaults() click to toggle source
# File lib/jsonapi-preloadable.rb, line 13
def defaults
  @defaults ||= Set.new
end
preload(*keys) click to toggle source
# File lib/jsonapi-preloadable.rb, line 31
def preload(*keys)
  keys = [keys] if keys.instance_of?(Symbol)
  defaults.merge(keys)
end