Skip to content

Instantly share code, notes, and snippets.

@mistersourcerer
Created October 28, 2011 18:16
Show Gist options
  • Save mistersourcerer/1322955 to your computer and use it in GitHub Desktop.
Save mistersourcerer/1322955 to your computer and use it in GitHub Desktop.
stevie_restfulando
class Cliente
include ActiveModel::Validations
include ActiveModel::Serialization
def initialize(params)
#pega o hash e seta os atributos normalmente.
end
# todos meus atributos e métodos normalmente aqui
end
class ClientesController < ApplicationController
def create
cliente = Cliente.new(params)
MeuServicoRemoto.new.grava_la(cliente)
end
end
class MeuServicoRemoto
def grava_la(um_model_qualquer)
faz_post(um_model_qualquer.to_json)
end
def exclui_de_la(um_model_qualquer)
faz_delete(um_model_qualquer.to_json)
end
private
def faz_post(data)
# post http normal aqui
end
def faz_delete(data)
# request http delete normal aqui
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment