Sha256: d243e3b030691b606f5091caff1c6d5b780057c465448dc90e6f0ce93ef72efc
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
class PeopleController < ApplicationController enable_push_route :index def index render json: Person.all, status: 200 end add_trigger :index, Person, :after_save enable_push_route :old, "/old_people" def old render json: Person.where("age > 50"), status: 200 end add_trigger(:old, Person, :after_update) do |person| (person.age_was <= 50 and person.age > 50) or (person.age_was > 50 and person.age <= 50) end enable_push_route :old_function, "/old_function" def old_function render json: Person.where("age > 80"), status: 200 end add_trigger :old_function, Person, :after_update, :old_function_trigger def old_function_trigger(person) (person.age_was <= 80 and person.age > 80) or (person.age_was > 80 and person.age <= 80) end enable_push_route :with_age def with_age render json: Person.where(age: params[:age]), status: 200 end add_trigger(:with_age, Person, :after_create) do |person| {age: person.age} end add_trigger(:with_age, Person, :after_update) do |person| if(person.age_was != person.age) [{age: person.age_was}, {age: person.age}] else false end end end
Version data entries
3 entries across 3 versions & 1 rubygems