module Mosca::CommandBuilder

Public Instance Methods

method_missing(method, *args) click to toggle source
# File lib/mosca/command_builder.rb, line 5
def method_missing(method, *args)
  json = full_hash(method, *args).to_json
  client.publish json
end

Protected Instance Methods

default_hash() click to toggle source
# File lib/mosca/command_builder.rb, line 12
def default_hash
  {}
end
process_command(command, args) click to toggle source
# File lib/mosca/command_builder.rb, line 16
def process_command command, args
  {command: command}
end

Private Instance Methods

full_hash(method, *args) click to toggle source
# File lib/mosca/command_builder.rb, line 30
def full_hash method, *args
  command_default = process_command(method, *args)
  command_specific = specific_hash(method, *args)
  default_hash.merge(command_default).merge(command_specific)
end
specific_hash(method, args) click to toggle source
# File lib/mosca/command_builder.rb, line 22
def specific_hash method, args
  hash = {}
  if respond_to? "#{method}_hash"
    hash.merge! send("#{method}_hash", args)
  end
  hash
end