Class: Audiences::Scim::Resource
- Inherits:
-
Object
- Object
- Audiences::Scim::Resource
- Defined in:
- lib/audiences/scim/resource.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, attributes: [], filter: nil, **options) ⇒ Resource
constructor
A new instance of Resource.
- #merged_filter(filter) ⇒ Object
- #query(**options) ⇒ Object
- #scim_attributes ⇒ Object
Constructor Details
#initialize(type:, attributes: [], filter: nil, **options) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 12 13 |
# File 'lib/audiences/scim/resource.rb', line 8 def initialize(type:, attributes: [], filter: nil, **) @type = type @options = @attributes = ["id", "externalId", "displayName", *attributes] @filter = filter end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/audiences/scim/resource.rb', line 6 def attributes @attributes end |
#filter ⇒ Object
Returns the value of attribute filter.
6 7 8 |
# File 'lib/audiences/scim/resource.rb', line 6 def filter @filter end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/audiences/scim/resource.rb', line 6 def @options end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/audiences/scim/resource.rb', line 6 def type @type end |
Instance Method Details
#merged_filter(filter) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/audiences/scim/resource.rb', line 36 def merged_filter(filter) return @filter unless filter return filter unless @filter "(#{@filter}) and (#{filter})" end |
#query(**options) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/audiences/scim/resource.rb', line 15 def query(**) = .delete(:filter) ResourcesQuery.new(Scim.client, resource: self, attributes: scim_attributes, filter: merged_filter(), **@options, **) end |
#scim_attributes ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/audiences/scim/resource.rb', line 23 def scim_attributes @attributes.reduce([]) do |attrs, attr| case attr when Hash attrs + attr.map do |key, nested_attrs| nested_attrs.map { "#{key}.#{_1}" } end else attrs + [attr] end end.join(",") end |