Class: Droonga::HandlerMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/handler_message.rb

Direct Known Subclasses

Test::StubHandlerMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ HandlerMessage

Returns a new instance of HandlerMessage.



19
20
21
# File 'lib/droonga/handler_message.rb', line 19

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



18
19
20
# File 'lib/droonga/handler_message.rb', line 18

def raw
  @raw
end

Instance Method Details

#[](name) ⇒ Object



33
34
35
# File 'lib/droonga/handler_message.rb', line 33

def [](name)
  @raw[name]
end

#bodyObject



37
38
39
# File 'lib/droonga/handler_message.rb', line 37

def body
  @body ||= self["body"]
end

#descendantsObject



57
58
59
# File 'lib/droonga/handler_message.rb', line 57

def descendants
  @descendants ||= body["descendants"]
end

#idObject



53
54
55
# File 'lib/droonga/handler_message.rb', line 53

def id
  @id ||= body["id"]
end

#requestObject



49
50
51
# File 'lib/droonga/handler_message.rb', line 49

def request
  @request ||= step["body"]
end

#stepObject



45
46
47
# File 'lib/droonga/handler_message.rb', line 45

def step
  @step ||= task["step"]
end

#taskObject



41
42
43
# File 'lib/droonga/handler_message.rb', line 41

def task
  @task ||= body["task"]
end

#validateObject



23
24
25
26
27
28
29
30
31
# File 'lib/droonga/handler_message.rb', line 23

def validate
  unless task.is_a?(Hash)
    raise "<task> value isn't object: <#{@raw.inspect}>"
  end

  unless step.is_a?(Hash)
    raise "<task/step> value isn't object: <#{@raw.inspect}>"
  end
end