Class: Scim::Kit::V2::Resource
- Inherits:
-
Object
- Object
- Scim::Kit::V2::Resource
show all
- Includes:
- ActiveModel::Validations, Templatable, Attributable
- Defined in:
- lib/scim/kit/v2/resource.rb
Overview
Represents a SCIM Resource
Direct Known Subclasses
Error
Instance Attribute Summary collapse
Instance Method Summary
collapse
#as_json, #render, #to_h, #to_json
#assign_attributes, #attribute_for, #define_attributes_for, #dynamic_attributes, #each, #read_attribute, #write_attribute
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.disable_timestamps
@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
12
13
14
|
# File 'lib/scim/kit/v2/resource.rb', line 12
def meta
@meta
end
|
#raw_attributes ⇒ Object
14
15
16
|
# File 'lib/scim/kit/v2/resource.rb', line 14
def raw_attributes
@raw_attributes
end
|
#schemas ⇒ Object
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
meta&.location
else
meta&.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
|