Module: JSONAPIonify::Api::Resource::Definitions::Contexts

Defined in:
lib/jsonapionify/api/resource/definitions/contexts.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



4
5
6
7
8
9
# File 'lib/jsonapionify/api/resource/definitions/contexts.rb', line 4

def self.extended(klass)
  klass.class_eval do
    extend JSONAPIonify::InheritedAttributes
    inherited_hash_attribute :context_definitions
  end
end

Instance Method Details

#context(name, **opts, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/jsonapionify/api/resource/definitions/contexts.rb', line 11

def context(name, **opts, &block)
  self.context_definitions[name.to_sym] = Context.new(
    name,
    **opts,
    existing_context: self.context_definitions[name.to_sym],
    &block
  )
end

#remove_context(name) ⇒ Object



20
21
22
# File 'lib/jsonapionify/api/resource/definitions/contexts.rb', line 20

def remove_context name
  self.context_definitions.delete(name)
end