Class: Scim::Kit::V2::Schema
- Inherits:
-
Object
- Object
- Scim::Kit::V2::Schema
show all
- Includes:
- Templatable
- Defined in:
- lib/scim/kit/v2/schema.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#as_json, #render, #template_name, #to_h, #to_json
Constructor Details
#initialize(id:, name:, location:) {|_self| ... } ⇒ Schema
Returns a new instance of Schema.
13
14
15
16
17
18
19
20
21
|
# File 'lib/scim/kit/v2/schema.rb', line 13
def initialize(id:, name:, location:)
@id = id
@name = name
@description = name
@meta = Meta.new('Schema', location)
@meta.created = @meta.last_modified = @meta.version = nil
@attributes = []
yield self if block_given?
end
|
Instance Attribute Details
#attributes ⇒ Object
10
11
12
|
# File 'lib/scim/kit/v2/schema.rb', line 10
def attributes
@attributes
end
|
#description ⇒ Object
11
12
13
|
# File 'lib/scim/kit/v2/schema.rb', line 11
def description
@description
end
|
#id ⇒ Object
10
11
12
|
# File 'lib/scim/kit/v2/schema.rb', line 10
def id
@id
end
|
11
12
13
|
# File 'lib/scim/kit/v2/schema.rb', line 11
def meta
@meta
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/scim/kit/v2/schema.rb', line 10
def name
@name
end
|
Class Method Details
.build(**args) {|item| ... } ⇒ Object
34
35
36
37
38
|
# File 'lib/scim/kit/v2/schema.rb', line 34
def build(**args)
item = new(**args)
yield item
item
end
|
.from(hash) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/scim/kit/v2/schema.rb', line 40
def from(hash)
Schema.new(
id: hash[:id],
name: hash[:name],
location: hash[:location]
) do |x|
x.meta = Meta.from(hash[:meta])
hash[:attributes].each do |y|
x.attributes << parse_attribute_type(y)
end
end
end
|
.parse(json) ⇒ Object
53
54
55
|
# File 'lib/scim/kit/v2/schema.rb', line 53
def parse(json)
from(JSON.parse(json, symbolize_names: true))
end
|
Instance Method Details
#add_attribute(name:, type: :string) {|attribute| ... } ⇒ Object
23
24
25
26
27
|
# File 'lib/scim/kit/v2/schema.rb', line 23
def add_attribute(name:, type: :string)
attribute = AttributeType.new(name: name, type: type, schema: self)
yield attribute if block_given?
attributes << attribute
end
|
#core? ⇒ Boolean
29
30
31
|
# File 'lib/scim/kit/v2/schema.rb', line 29
def core?
id.include?(Schemas::CORE) || id.include?(Messages::CORE)
end
|