Class: HasuraHandler::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/hasura_handler/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Event

Returns a new instance of Event.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hasura_handler/event.rb', line 13

def initialize(event)
  @id = event['id']
  @table = event['table']['name']
  @schema = event['table']['schema']
  @trigger = event['trigger']['name']
  @event = event['event']
  @op = event['event']['op']
  @created_at = event['created_at']
  @raw_event = event
  @errors = {}

  [
    :validate_simple_fields,
    :validate_table,
    :validate_trigger,
    :validate_event
  ].each{ |check| self.send(check) }
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def created_at
  @created_at
end

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def errors
  @errors
end

#eventObject (readonly)

Returns the value of attribute event.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def event
  @event
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def id
  @id
end

#opObject (readonly)

Returns the value of attribute op.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def op
  @op
end

#raw_eventObject (readonly)

Returns the value of attribute raw_event.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def raw_event
  @raw_event
end

#schemaObject (readonly)

Returns the value of attribute schema.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def schema
  @schema
end

#tableObject (readonly)

Returns the value of attribute table.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def table
  @table
end

#triggerObject (readonly)

Returns the value of attribute trigger.



3
4
5
# File 'lib/hasura_handler/event.rb', line 3

def trigger
  @trigger
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/hasura_handler/event.rb', line 32

def valid?
  @errors.blank?
end