Class: Vigia::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/vigia/adapter.rb

Defined Under Namespace

Classes: Structure

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#source_fileObject

Returns the value of attribute source_file.



4
5
6
# File 'lib/vigia/adapter.rb', line 4

def source_file
  @source_file
end

#structureObject

Returns the value of attribute structure.



4
5
6
# File 'lib/vigia/adapter.rb', line 4

def structure
  @structure
end

Class Method Details

.instanceObject



16
17
18
19
20
21
22
# File 'lib/vigia/adapter.rb', line 16

def instance
  new.tap do |object|
    object.source_file = Vigia.config.source_file
    object.structure   = Structure.generate(object, @template)
    object
  end
end

.setup_adapter(&block) ⇒ Object



7
8
9
10
# File 'lib/vigia/adapter.rb', line 7

def setup_adapter(&block)
  raise 'You have to call config_adapter with a block' unless block_given?
  @template = block
end

.templateObject



12
13
14
# File 'lib/vigia/adapter.rb', line 12

def template
  @template
end

Instance Method Details

#required_payload?(method) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/vigia/adapter.rb', line 29

def required_payload?(method)
  [ :post, :patch, :put ].include?(method.to_s.downcase.to_sym)
end

#with_payload?(method) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/vigia/adapter.rb', line 25

def with_payload?(method)
  [ :post, :patch, :put, :delete ].include?(method.to_s.downcase.to_sym)
end