Module: TicketEvolution::Modules::Destroy

Included in:
Clients::Addresses, Clients::CreditCards, Companies, Offices::CreditCards
Defined in:
lib/ticket_evolution/modules/destroy.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ticket_evolution/modules/destroy.rb', line 4

def self.included(klass)
  Class.new{extend SingularClass}.singular_class(klass.name).send(:include, Module.new{
    def destroy
      response = endpoint.try(:destroy)
      if response === true
        self.freeze
      end

      response
    end

    alias :delete :destroy
  })
end

Instance Method Details

#build_for_destroy(response) ⇒ Object



25
26
27
# File 'lib/ticket_evolution/modules/destroy.rb', line 25

def build_for_destroy(response)
  response.body
end

#destroy(&handler) ⇒ Object



19
20
21
22
23
# File 'lib/ticket_evolution/modules/destroy.rb', line 19

def destroy(&handler)
  ensure_id
  handler ||= method(:build_for_destroy)
  request(:DELETE, nil, nil, &handler)
end