Sha256: e62b6becdc0af58d06e988ff74a47b7c2c801d1b8385646e96e07323399c4d3b

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

class <%=class_name%> < Rhoconnect::Model::Base
  def initialize(source) 
    super(source)
  end
 
  def login
    # TODO: Login to your data source here if necessary
  end
 
  def query(params=nil)
    # TODO: Query your backend data source and assign the records 
    # to a nested hash structure called @result. For example:
    # @result = { 
    #   "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
    #   "2"=>{"name"=>"Best", "industry"=>"Software"}
    # }
    raise Rhoconnect::Model::Exception.new("Please provide some code to read records from the backend data source")
  end

  def create(create_hash)
    # TODO: Create a new record in your backend data source
    raise "Please provide some code to create a single record in the backend data source using the create_hash"
  end
 
  def update(update_hash)
    # TODO: Update an existing record in your backend data source
    raise "Please provide some code to update a single record in the backend data source using the update_hash"
  end
 
  def delete(delete_hash)
    # TODO: write some code here if applicable
    # be sure to have a hash key and value for "object"
    # for now, we'll say that its OK to not have a delete operation
    # raise "Please provide some code to delete a single object in the backend application using the object_id"
  end
 
  def logoff
    # TODO: Logout from the data source if necessary
  end

  # Calling super here returns rack tempfile path:
  # i.e. /var/folders/J4/J4wGJ-r6H7S313GEZ-Xx5E+++TI
  # Note: This tempfile is removed when server stops or crashes...
  # See http://rack.rubyforge.org/doc/Multipart.html for more info
  #
  # Uncomment this code and override it by creating a copy of the file somewhere
  # and returning the path to that file (then don't call super!):
  # i.e. /mnt/myimages/soccer.png
  #def store_blob(object,field_name,blob)
  #  super #=> returns blob[:tempfile]
  #end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rhoconnect-4.0.0.beta.10 generators/templates/source/models/ruby/model.rb
rhoconnect-4.0.0.beta.12 generators/templates/source/models/ruby/model.rb