Skip to content

Instantly share code, notes, and snippets.

@willb
Created November 24, 2009 16:20
Show Gist options
  • Save willb/241988 to your computer and use it in GitHub Desktop.
Save willb/241988 to your computer and use it in GitHub Desktop.
require 'spqr/spqr'
require 'spqr/app'
require 'examples/codegen/EchoAgent'
app = SPQR::App.new(:loglevel => :debug)
app.register Examples::Codegen::EchoAgent
app.main
<schema package="examples.codegen">
<class name="EchoAgent">
<method name="echo" desc="returns its argument">
<arg name="arg" dir="IO" type="lstr"/>
</method>
</class>
</schema>
module Examples
module Codegen
class EchoAgent
include SPQR::Manageable
# Find method (NB: you must implement this)
def EchoAgent.find_by_id(objid)
EchoAgent.new
end
# Find-all method (NB: you must implement this)
def EchoAgent.find_all
[EchoAgent.new]
end
### Schema method declarations
# echo returns its argument
# * arg (lstr/IO)
#
def echo(args)
# Print values of in/out parameters
log.debug "arg => #{args["arg"]}" #
# Assign values to in/out parameters
args["arg"] = args["arg"]
end
spqr_expose :echo do |args|
args.declare :arg, :lstr, :inout, {}
end
end
end
end
module Examples
module Codegen
class EchoAgent
include SPQR::Manageable
# Find method (NB: you must implement this)
def EchoAgent.find_by_id(objid)
EchoAgent.new
end
# Find-all method (NB: you must implement this)
def EchoAgent.find_all
[EchoAgent.new]
end
### Schema method declarations
# echo returns its argument
# * arg (lstr/IO)
#
def echo(args)
# Print values of in/out parameters
log.debug "arg => #{args["arg"]}" #
# Assign values to in/out parameters
args["arg"] = args["arg"]
end
spqr_expose :echo do |args|
args.declare :arg, :lstr, :inout, {}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment