module Scim::Kit::Templatable
Implement methods necessary to generate json from jbuilder templates.
Public Instance Methods
as_json(_options = nil)
click to toggle source
Returns the hash representation of the JSON @return [Hash] the hash representation of the items JSON.
# File lib/scim/kit/templatable.rb, line 16 def as_json(_options = nil) to_h end
render(model, options)
click to toggle source
Renders the model to JSON. @param model [Object] the model to render. @param options [Hash] the hash of options to pass to jbuilder. @return [String] the JSON.
# File lib/scim/kit/templatable.rb, line 30 def render(model, options) Template.new(model).to_json(options) end
template_name()
click to toggle source
Returns the file name of the jbuilder template. @return [String] name of the jbuilder template.
# File lib/scim/kit/templatable.rb, line 36 def template_name "#{self.class.name.split('::').last.underscore}.json.jbuilder" end
to_h()
click to toggle source
Returns the hash representation of the JSON @return [Hash] the hash representation of the items JSON.
# File lib/scim/kit/templatable.rb, line 22 def to_h JSON.parse(to_json, symbolize_names: true).with_indifferent_access end
to_json(options = {})
click to toggle source
Returns the JSON representation of the item. @param options [Hash] the hash of options to forward to jbuilder return [String] the json string
# File lib/scim/kit/templatable.rb, line 10 def to_json(options = {}) render(self, options) end