Class: OdataDuty::SchemaBuilder::EntitySet

Inherits:
Container
  • Object
show all
Defined in:
lib/odata_duty/schema_builder/entity_set.rb

Instance Attribute Summary collapse

Attributes inherited from Container

#_defined_at_, #name

Instance Method Summary collapse

Constructor Details

#initialize(entity_type:, resolver:, name: nil, url: nil, init_args: nil, description: nil) ⇒ EntitySet

Returns a new instance of EntitySet.



9
10
11
12
13
14
15
16
17
18
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 9

def initialize(entity_type:, resolver:, name: nil, url: nil, init_args: nil,
               description: nil)
  @resolver = resolver.clone
  name = name&.to_s || @resolver.split('::').last.sub(/Resolver\z/, '')
  super(name: name)
  @url = (url&.to_s || @name).clone
  @entity_type = entity_type
  @init_args = init_args
  @description = Property.resolve_description(@name, description)
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 7

def description
  @description
end

#entity_typeObject (readonly)

Returns the value of attribute entity_type.



7
8
9
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 7

def entity_type
  @entity_type
end

#init_argsObject (readonly)

Returns the value of attribute init_args.



7
8
9
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 7

def init_args
  @init_args
end

#resolverObject (readonly)

Returns the value of attribute resolver.



7
8
9
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 7

def resolver
  @resolver
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 7

def url
  @url
end

Instance Method Details

#entity_type_nameObject



20
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 20

def entity_type_name = entity_type.name

#non_insertable_property_namesObject



63
64
65
66
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 63

def non_insertable_property_names
  @non_insertable_property_names ||=
    entity_type.properties.select(&:non_insertable?).map(&:name)
end

#resolver_classObject



22
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 22

def resolver_class = Module.const_get(resolver)

#supports_collection?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 33

def supports_collection?
  # Check if the resolver class supports read by looking for the collection method
  resolver_class.method_defined?(:collection)
end

#supports_count?Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 43

def supports_count?
  # Check if the resolver class supports counting via the count method
  resolver_class.method_defined?(:count)
end

#supports_create?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 48

def supports_create?
  # Check if the resolver class supports create by looking for the create method
  resolver_class.method_defined?(:create)
end

#supports_delete?Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 58

def supports_delete?
  # Check if the resolver class supports delete by looking for the delete method
  resolver_class.method_defined?(:delete)
end

#supports_filter_or?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 29

def supports_filter_or?
  resolver_class.method_defined?(:od_filter_or)
end

#supports_individual?Boolean

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 38

def supports_individual?
  # Check if the resolver class supports read-by-id via the individual method
  resolver_class.method_defined?(:individual)
end

#supports_search?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 24

def supports_search?
  # Check if the resolver class supports search by looking for the od_search method
  resolver_class.method_defined?(:od_search)
end

#supports_update?Boolean

Returns:

  • (Boolean)


53
54
55
56
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 53

def supports_update?
  # Check if the resolver class supports update by looking for the update method
  resolver_class.method_defined?(:update)
end