Commit 7013be7
Changed files (3)
lib
scim
kit
lib/scim/kit/v2/templates/attribute_type.json.jbuilder
@@ -12,6 +12,6 @@ json.caseExact(case_exact) if string? || reference?
json.referenceTypes(reference_types) if reference?
if complex?
json.subAttributes attributes do |attribute|
- Scim::Kit::Template.new(attribute).to_json(json: json)
+ render attribute, json: json
end
end
lib/scim/kit/v2/templates/schema.json.jbuilder
@@ -8,5 +8,5 @@ json.meta do
json.location location
end
json.attributes attributes do |attribute|
- Scim::Kit::Template.new(attribute).to_json(json: json)
+ render attribute, json: json
end
lib/scim/kit/templatable.rb
@@ -4,13 +4,17 @@ module Scim
module Kit
# Implement methods necessary to generate json from jbuilder templates.
module Templatable
- def to_json
- Template.new(self).to_json
+ def to_json(options = {})
+ render(self, options)
end
def to_h
JSON.parse(to_json, symbolize_names: true)
end
+
+ def render(model, options)
+ Template.new(model).to_json(options)
+ end
end
end
end