Sha256: ff78fb34de95a89a53f594d11c2de58aa779a89b242272bd3a9b1c0b28af9c31
Contents?: true
Size: 751 Bytes
Versions: 1
Compression:
Stored size: 751 Bytes
Contents
# frozen_string_literal: true module Alba # Rails integration class Railtie < Rails::Railtie initializer 'alba.initialize' do Alba.inflector = :active_support ActiveSupport.on_load(:action_controller) do define_method(:serialize) do |obj, with: nil, root_key: nil, meta: {}, &block| resource = with.nil? ? Alba.resource_with(obj, &block) : with.new(obj) resource.to_json(root_key: root_key, meta: meta) end define_method(:render_serialized_json) do |obj, with: nil, root_key: nil, meta: {}, &block| json = with.nil? ? Alba.resource_with(obj, &block) : with.new(obj) render json: json.to_json(root_key: root_key, meta: meta) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alba-3.5.0 | lib/alba/railtie.rb |