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
- #raw_attributes ⇒ Object readonly
- #schemas ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(schemas:, location: nil, attributes: {}) {|_self| ... } ⇒ Resource
constructor
A new instance of Resource.
-
#mode?(type) ⇒ Boolean
Returns the current mode.
-
#template_name ⇒ String
Returns the name of the jbuilder template file.
Methods included from Templatable
#as_json, #render, #to_h, #to_json
Methods included from Attributable
#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. @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)
12 13 14 |
# File 'lib/scim/kit/v2/resource.rb', line 12 def @meta end |
#raw_attributes ⇒ Object (readonly)
14 15 16 |
# File 'lib/scim/kit/v2/resource.rb', line 14 def raw_attributes @raw_attributes end |
#schemas ⇒ Object (readonly)
13 14 15 |
# File 'lib/scim/kit/v2/resource.rb', line 13 def schemas @schemas end |
Instance Method Details
#mode?(type) ⇒ Boolean
Returns the current mode.
34 35 36 37 38 39 40 41 |
# File 'lib/scim/kit/v2/resource.rb', line 34 def mode?(type) case type.to_sym when :server &.location else &.location.nil? end end |
#template_name ⇒ String
Returns the name of the jbuilder template file.
45 46 47 |
# File 'lib/scim/kit/v2/resource.rb', line 45 def template_name 'resource.json.jbuilder' end |