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) ⇒ EntitySet

Returns a new instance of EntitySet.



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

def initialize(entity_type:, resolver:, name: nil, url: nil, init_args: 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
end

Instance Attribute Details

#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



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

def entity_type_name = entity_type.name

#non_insertable_property_namesObject



61
62
63
64
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 61

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

#resolver_classObject



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

def resolver_class = Module.const_get(resolver)

#supports_collection?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 31

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)


41
42
43
44
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 41

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)


46
47
48
49
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 46

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)


56
57
58
59
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 56

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)


27
28
29
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 27

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

#supports_individual?Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 36

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)


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

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)


51
52
53
54
# File 'lib/odata_duty/schema_builder/entity_set.rb', line 51

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