Module: Anoubis::Data::Callbacks

Included in:
Anoubis::DataController
Defined in:
app/controllers/anoubis/data/callbacks.rb

Overview

Module presents all callbacks called in actions.

Instance Method Summary collapse

Instance Method Details

#after_create_dataObject

Fires after data was was created on the server and placed in self.output.data array. It’s rewrote for change data before output.



40
41
42
# File 'app/controllers/anoubis/data/callbacks.rb', line 40

def after_create_data

end

#after_get_table_dataObject

Fires after data was received from server and placed in self.output.data array. It’s rewrote for change data before output.



9
10
11
# File 'app/controllers/anoubis/data/callbacks.rb', line 9

def after_get_table_data

end

#after_update_dataObject

Fires after data was was updated on the server and placed in self.output.data array. It’s rewrote for change data before output.



24
25
26
# File 'app/controllers/anoubis/data/callbacks.rb', line 24

def after_update_data

end

#around_output(data) ⇒ Object

Fires when data output to json value



52
53
54
# File 'app/controllers/anoubis/data/callbacks.rb', line 52

def around_output(data)
  data
end

#before_create_data(data) ⇒ Hash

Fires after data was was created in self.output.data array and before it saved to server. It’s rewrote for change data before output.

Parameters:

  • data (Hash)

    Data for create

Returns:

  • (Hash)

    Processed data. If returned nil then update is terminated.



33
34
35
# File 'app/controllers/anoubis/data/callbacks.rb', line 33

def before_create_data(data)
  data
end

#before_outputObject

Fires right before output data to screen



46
47
48
# File 'app/controllers/anoubis/data/callbacks.rb', line 46

def before_output

end

#before_update_data(data) ⇒ Hash

Fires before data will be verified and converted.

Parameters:

  • data (Hash)

    Data for update

Returns:

  • (Hash)

    Processed data. If returned nil then update is terminated.



17
18
19
# File 'app/controllers/anoubis/data/callbacks.rb', line 17

def before_update_data(data)
  data
end

#destroy_dataObject

Fires when data is destroyed



58
59
60
61
62
63
# File 'app/controllers/anoubis/data/callbacks.rb', line 58

def destroy_data
  if !self.etc.data.data.destroy
    self.output.errors.concat self.etc.data.data.errors.full_messages
    self.output.result = -4
  end
end