Module: InstantRecord::RuntimeScoped

Defined in:
lib/instant_record/runtime_scoped.rb

Overview

Class-level blocks that only exist in one runtime. Syncable models get these automatically; any other class (controllers, jobs, POROs) opts in:

class IssuesController < ApplicationController
extend InstantRecord::RuntimeScoped

server_only do
  before_action :authenticate_user!   # sessions exist only on the server
end
end

Instance Method Summary collapse

Instance Method Details

#browser_only(&block) ⇒ Object



17
18
19
# File 'lib/instant_record/runtime_scoped.rb', line 17

def browser_only(&block)
  class_eval(&block) if InstantRecord.browser?
end

#server_only(&block) ⇒ Object



13
14
15
# File 'lib/instant_record/runtime_scoped.rb', line 13

def server_only(&block)
  class_eval(&block) unless InstantRecord.browser?
end