Module: Databound::Initializer

Defined in:
lib/databound/initializer.rb

Instance Method Summary collapse

Instance Method Details

#databound(model = nil, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/databound/initializer.rb', line 3

def databound(model = nil, &block)
  include Databound

  send(:before_filter, :init_crud, only: %i(where create update destroy))
  send(:define_method, :databound_config) do
    Databound::Config.new(block, model)
  end

  if Rails.application.config.consider_all_requests_local
    rescue_from Databound::NotPermittedError do |exception|
      render(
        status: Databound::NotPermittedError::STATUS,
        json: {
          message: exception.to_s,
        },
      )
    end
  end
end