Czesc,
Piszę aplikację, która używać będzie tego gemu: https://github.com/thoughtfusion/suitcase.
Nie mam doświadczenia w pisaniu aplikacji używających jako bazy zewnetrznego API.
Macie jakieś uwagi przy projektowaniu takich aplikacji?
Narazie aby mieć ladna dokumentacje w modelach oraz wszystko w jednym miejscu w przypadku, gdyby API się zmienilo. Stworzylem klasy bez ActiveRecorda:
[code=ruby]class Hotel
API
Find Hotel by id
Result: Hotel details
Example:
Hotel.find(215962)
def self.find(id)
Suitcase::Hotel.find(id: id)
end
Find Hotel by location(city)
Result: Array of hotels from that location
Example:
Hotel.find_by_location(“New York”)
def self.find_by_location(location)
Suitcase::Hotel.find(location: location)
end
end
#room.rb
class Room
Find room for specific hotel
Result: Array of rooms for specific hotel
Example:
Room.find_by_hotel(242047, “05-28-2012”, “05-29-2012”)
def self.find_by_hotel(hotel_id, arrival, departure)
Suitcase::Hotel.find(id: hotel_id).rooms(arrival: arrival, departure: departure)
end
end[/code]
Zastanawiam sie czy jest w takim razie mozliwe dodanie tego typu metody:
class Hotel
...
def self.rooms(arrival, departure)
self.rooms(arrival: arrival, departure: departure)
end
...
Co oczywiscie nie moze dzialac gdyz klasa self w tym przypadku to Suitcase::Hotel.
Może powinienem, użyć czegoś typu https://github.com/cgriego/active_attr ??