LHS
LHS uses LHC for http requests.
Service
A service connects your application to backend endpoints and provides you access to their data.
class Feedback < LHS::Service
endpoint ':datastore/v2/content-ads/:campaign_id/feedbacks'
endpoint ':datastore/v2/feedbacks'
end
data = Feedback.where(has_reviews: true) #<LHS::Data>
Data
An instance of LHS::Data contains raw data (json) and a proxy that is used to access data.
Service.where #<LHS::Data @_proxy_=#<LHS::Collection>>
Service.find(123) #<LHS::Data @_proxy_=#<LHS::Item>>
Proxy
A proxy is used to access data. It is divided in Collection and Item.
For every proxy that contains an href you can use load! or reload! to receive latest backend data.
{
"href" => "http://datastore-stg.lb-service.sunrise.intra.local.ch/v2/content-ads/51dfc5690cf271c375c5a12d"
}
item.load!.id
item.reload! # loads it again
item.load! # wont load it again, because its already arround
Collection
A collection contains multiple items.
data = Feedback.where(has_reviews: true) #<LHS::Data @_proxy_=#<LHS::Collection>>
data.count # 10
data.total # 98
Item
An item is a concrete record. It can be part of another proxy like collection.
data = Feedback.where(has_reviews: true).first #<LHS::Data @_proxy_=#<LHS::Item>>
data.recommended # true
data.created_date # Fri, 19 Sep 2014 14:03:35 +0200