Sha256: 29f74db8fdf27714cd32ce63a4a74358f3866ca36392e452dc942f9541e65729

Contents?: true

Size: 493 Bytes

Versions: 12

Compression:

Stored size: 493 Bytes

Contents

# frozen_string_literal: true

module Scim
  module Kit
    # Implement methods necessary to generate json from jbuilder templates.
    module Templatable
      def to_json(options = {})
        render(self, options)
      end

      def as_json(_options = nil)
        to_h
      end

      def to_h
        JSON.parse(to_json, symbolize_names: true).with_indifferent_access
      end

      def render(model, options)
        Template.new(model).to_json(options)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
scim-kit-0.2.13 lib/scim/kit/templatable.rb
scim-kit-0.2.12 lib/scim/kit/templatable.rb
scim-kit-0.2.11 lib/scim/kit/templatable.rb
scim-kit-0.2.10 lib/scim/kit/templatable.rb
scim-kit-0.2.9 lib/scim/kit/templatable.rb
scim-kit-0.2.8 lib/scim/kit/templatable.rb
scim-kit-0.2.7 lib/scim/kit/templatable.rb
scim-kit-0.2.6 lib/scim/kit/templatable.rb
scim-kit-0.2.5 lib/scim/kit/templatable.rb
scim-kit-0.2.4 lib/scim/kit/templatable.rb
scim-kit-0.2.3 lib/scim/kit/templatable.rb
scim-kit-0.2.2 lib/scim/kit/templatable.rb