Skip to content

Instantly share code, notes, and snippets.

@alto
Created October 7, 2011 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alto/1269784 to your computer and use it in GitHub Desktop.
Save alto/1269784 to your computer and use it in GitHub Desktop.
object @place => :place
# this is a hack, but otherwise the partial mechanism doesn't work yet [thorsten, 2011-10-07]
@place = @_data.is_a?(Hash) ? @_data.keys.first : @_data
attributes :name, :city, :street, :slug, :zipcode, :phone, :number_of_beds, :number_of_bedrooms,
:currency, :lat, :lng, :scouts_approved_at, :district, :number_of_bathrooms, :cancellation_rules,
:charge_per_extra_person, :minimum_nights, :maximum_nights, :bed_type,
:size, :manual, :house_rules, :pets_around, :emergency_phone, :bathroom_type, :cleaning_fee,
:charge_per_extra_person_limit, :favorites_count, :state, :amenities_list
node(:price) { |p| p.price.to_f }
node(:country) { |p| I18n.t("countries.#{p.country}") }
node(:category) { |p| I18n.t("places.categories.#{p.category}") }
node(:place_type) { |p| I18n.t("places.types.#{p.place_type}") }
node(:bed_type) { |p| I18n.t("places.bed_types.#{p.bed_type}") }
node(:bathroom_type) { |p| I18n.t("places.bathroom_types.#{p.bathroom_type}") }
child(:host => :host) { attributes :name, :slug }
node(:links) do
[
{ :rel => 'self', :href => api_place_url(:id => @place.to_param, :client_id => @client_application.to_param)}
]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment