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) ⇒ Object
- #render(model, options) ⇒ Object
- #template_name ⇒ Object
- #to_h ⇒ Object
- #to_json(options = {}) ⇒ Object
Instance Method Details
#as_json(_options = nil) ⇒ Object
11 12 13 |
# File 'lib/scim/kit/templatable.rb', line 11 def as_json( = nil) to_h end |
#render(model, options) ⇒ Object
19 20 21 |
# File 'lib/scim/kit/templatable.rb', line 19 def render(model, ) Template.new(model).to_json() end |
#template_name ⇒ Object
23 24 25 |
# File 'lib/scim/kit/templatable.rb', line 23 def template_name "#{self.class.name.split('::').last.underscore}.json.jbuilder" end |
#to_h ⇒ Object
15 16 17 |
# File 'lib/scim/kit/templatable.rb', line 15 def to_h JSON.parse(to_json, symbolize_names: true).with_indifferent_access end |
#to_json(options = {}) ⇒ Object
7 8 9 |
# File 'lib/scim/kit/templatable.rb', line 7 def to_json( = {}) render(self, ) end |