Skip to content

Instantly share code, notes, and snippets.

@pezra
Created July 6, 2010 23:30
Show Gist options
  • Save pezra/466086 to your computer and use it in GitHub Desktop.
Save pezra/466086 to your computer and use it in GitHub Desktop.
class MyResource
include Spinal::Resource
representation :json, :direction => :in_and_out do |rep|
rep.attribute :foo
rep.attribute :bar, :required => true
end
representation :url_encoded_form_data, :direction => :in do |rep|
rep.attribute :foo
rep.attribute :bar, :required => true
end
repesentation :html, :direction => :out do |rep|
rep.attribute :foo
rep.attribute :bar
rep.attribute :current_user
end
def get()
# ...
create_representation(:foo => my_model.foo, :bar => my_model.bar, :current_user => current_user)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment