Module: Scim::Kit::Templatable
- Included in:
- V2::Attribute, V2::AttributeType, V2::AuthenticationScheme, V2::Meta, V2::Resource, V2::ResourceType, V2::Schema, V2::ServiceProviderConfiguration, V2::Supportable
- Defined in:
- lib/scim/kit/templatable.rb
Overview
Implement methods necessary to generate json from jbuilder templates.
Instance Method Summary collapse
-
#as_json(_options = nil) ⇒ Hash
Returns the hash representation of the JSON.
-
#render(model, options) ⇒ String
Renders the model to JSON.
-
#template_name ⇒ String
Returns the file name of the jbuilder template.
-
#to_h ⇒ Hash
Returns the hash representation of the JSON.
-
#to_json(options = {}) ⇒ Object
Returns the JSON representation of the item.
Instance Method Details
#as_json(_options = nil) ⇒ Hash
Returns the hash representation of the JSON
16 17 18 |
# File 'lib/scim/kit/templatable.rb', line 16 def as_json( = nil) to_h end |
#render(model, options) ⇒ String
Renders the model to JSON.
30 31 32 |
# File 'lib/scim/kit/templatable.rb', line 30 def render(model, ) Template.new(model).to_json() end |
#template_name ⇒ String
Returns the file name of the jbuilder template.
36 37 38 |
# File 'lib/scim/kit/templatable.rb', line 36 def template_name "#{self.class.name.split('::').last.underscore}.json.jbuilder" end |
#to_h ⇒ Hash
Returns the hash representation of the JSON
22 23 24 |
# 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 = {}) ⇒ Object
Returns the JSON representation of the item. return [String] the json string
10 11 12 |
# File 'lib/scim/kit/templatable.rb', line 10 def to_json( = {}) render(self, ) end |