crepe / jsonite

A tiny, HAL-compliant JSON presenter for your Ruby APIs.
28 stars 2 forks source link

Add .let to define memoized "virtual" methods on presenter resource #17

Closed kainosnoema closed 9 years ago

kainosnoema commented 9 years ago

For some reason the .let and .lets methods were added in f312bc8, but they weren't implemented. This completes a basic implementation which defines "virtual" memoized methods on the resource.

Example:

class UserPresenter < Jsonite
  let(:full_name) { "#{first_name} #{last_name}" }
  property :full_name
end
# {
#   "full_name": "Stephen Celis"
# }

Downsides: