Class: Scim::Kit::V2::Resource
- Inherits:
-
Object
- Object
- Scim::Kit::V2::Resource
- Includes:
- ActiveModel::Validations, Templatable, Attributable
- Defined in:
- lib/scim/kit/v2/resource.rb
Overview
Represents a SCIM Resource
Direct Known Subclasses
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#raw_attributes ⇒ Object
readonly
Returns the value of attribute raw_attributes.
-
#schemas ⇒ Object
readonly
Returns the value of attribute schemas.
Instance Method Summary collapse
-
#initialize(schemas:, location: nil, attributes: {}) {|_self| ... } ⇒ Resource
constructor
A new instance of Resource.
- #mode?(type) ⇒ Boolean
- #template_name ⇒ Object
Methods included from Templatable
#as_json, #render, #to_h, #to_json
Methods included from Attributable
#assign_attributes, #define_attributes_for, #dynamic_attributes
Constructor Details
#initialize(schemas:, location: nil, attributes: {}) {|_self| ... } ⇒ Resource
Returns a new instance of Resource.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scim/kit/v2/resource.rb', line 18 def initialize(schemas:, location: nil, attributes: {}) @meta = Meta.new(schemas[0]&.name, location) @meta. @schemas = schemas @raw_attributes = attributes schemas.each { |x| define_attributes_for(self, x.attributes) } attribute(AttributeType.new(name: :id), self) attribute(AttributeType.new(name: :external_id), self) assign_attributes(attributes) yield self if block_given? end |
Instance Attribute Details
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
12 13 14 |
# File 'lib/scim/kit/v2/resource.rb', line 12 def @meta end |
#raw_attributes ⇒ Object (readonly)
Returns the value of attribute raw_attributes.
14 15 16 |
# File 'lib/scim/kit/v2/resource.rb', line 14 def raw_attributes @raw_attributes end |
#schemas ⇒ Object (readonly)
Returns the value of attribute schemas.
13 14 15 |
# File 'lib/scim/kit/v2/resource.rb', line 13 def schemas @schemas end |
Instance Method Details
#mode?(type) ⇒ Boolean
30 31 32 33 34 35 36 37 |
# File 'lib/scim/kit/v2/resource.rb', line 30 def mode?(type) case type.to_sym when :server &.location else &.location.nil? end end |
#template_name ⇒ Object
39 40 41 |
# File 'lib/scim/kit/v2/resource.rb', line 39 def template_name 'resource.json.jbuilder' end |