Class: OdataDuty::SchemaBuilder::Schema
- Inherits:
-
Object
- Object
- OdataDuty::SchemaBuilder::Schema
- Defined in:
- lib/odata_duty/schema_builder.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#title ⇒ Object
Returns the value of attribute title.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #add_complex_type(**kwargs, &block) ⇒ Object
- #add_entity_set(**kwargs) ⇒ Object
- #add_entity_type(**kwargs, &block) ⇒ Object
- #add_enum_type(**kwargs, &block) ⇒ Object
- #collection_entity_sets ⇒ Object
- #complex_types ⇒ Object
- #create(url, context:, query_options: nil) ⇒ Object
- #delete(url, context:, query_options: nil) ⇒ Object
- #endpoints ⇒ Object
- #entity_sets ⇒ Object
- #entity_types ⇒ Object
- #enum_types ⇒ Object
- #execute(url, context:, query_options: {}) ⇒ Object
- #index_hash ⇒ Object
- #individual_entity_sets ⇒ Object
-
#initialize(namespace:, host: 'localhost', scheme: 'https', base_path: '') ⇒ Schema
constructor
A new instance of Schema.
- #inspect ⇒ Object
- #metadata_xml ⇒ Object
- #to_mcp_server ⇒ Object
- #update(url, context:, query_options: nil) ⇒ Object
Constructor Details
#initialize(namespace:, host: 'localhost', scheme: 'https', base_path: '') ⇒ Schema
Returns a new instance of Schema.
17 18 19 20 21 22 23 24 25 |
# File 'lib/odata_duty/schema_builder.rb', line 17 def initialize(namespace:, host: 'localhost', scheme: 'https', base_path: '') @namespace = namespace.to_str.clone.freeze @host = host.to_str.clone.freeze @scheme = scheme.to_str.clone.freeze @base_path = base_path.to_str.clone.freeze @base_url = [scheme, '://', host, base_path].join.freeze @types = {} @containers = {} end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
14 15 16 |
# File 'lib/odata_duty/schema_builder.rb', line 14 def base_path @base_path end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
14 15 16 |
# File 'lib/odata_duty/schema_builder.rb', line 14 def base_url @base_url end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/odata_duty/schema_builder.rb', line 14 def host @host end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
14 15 16 |
# File 'lib/odata_duty/schema_builder.rb', line 14 def namespace @namespace end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
14 15 16 |
# File 'lib/odata_duty/schema_builder.rb', line 14 def scheme @scheme end |
#title ⇒ Object
Returns the value of attribute title.
15 16 17 |
# File 'lib/odata_duty/schema_builder.rb', line 15 def title @title end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
14 15 16 |
# File 'lib/odata_duty/schema_builder.rb', line 14 def types @types end |
#version ⇒ Object
Returns the value of attribute version.
15 16 17 |
# File 'lib/odata_duty/schema_builder.rb', line 15 def version @version end |
Instance Method Details
#add_complex_type(**kwargs, &block) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/odata_duty/schema_builder.rb', line 32 def add_complex_type(**kwargs, &block) ComplexType.new(**kwargs).tap do |complex_type| add_type complex_type block.call(complex_type) end end |
#add_entity_set(**kwargs) ⇒ Object
53 54 55 |
# File 'lib/odata_duty/schema_builder.rb', line 53 def add_entity_set(**kwargs) EntitySet.new(**kwargs).tap { |entity_set| add_container(entity_set) } end |
#add_entity_type(**kwargs, &block) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/odata_duty/schema_builder.rb', line 46 def add_entity_type(**kwargs, &block) EntityType.new(**kwargs).tap do |entity_type| add_type entity_type block.call(entity_type) end end |
#add_enum_type(**kwargs, &block) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/odata_duty/schema_builder.rb', line 39 def add_enum_type(**kwargs, &block) EnumType.new(**kwargs).tap do |enum_type| add_type enum_type block.call(enum_type) end end |
#collection_entity_sets ⇒ Object
75 76 77 |
# File 'lib/odata_duty/schema_builder.rb', line 75 def collection_entity_sets entity_sets.select { |t| t.resolver_class.method_defined?(:collection) } end |
#complex_types ⇒ Object
65 66 67 |
# File 'lib/odata_duty/schema_builder.rb', line 65 def complex_types all_types.select { |t| t.instance_of?(ComplexType) } end |
#create(url, context:, query_options: nil) ⇒ Object
87 88 89 |
# File 'lib/odata_duty/schema_builder.rb', line 87 def create(url, context:, query_options: nil) Executor.create(url: url, context: context, query_options: , schema: self) end |
#delete(url, context:, query_options: nil) ⇒ Object
95 96 97 |
# File 'lib/odata_duty/schema_builder.rb', line 95 def delete(url, context:, query_options: nil) Executor.delete(url: url, context: context, query_options: , schema: self) end |
#endpoints ⇒ Object
57 58 59 |
# File 'lib/odata_duty/schema_builder.rb', line 57 def endpoints entity_sets.map { |entity_set| Endpoint.new(entity_set) } end |
#entity_sets ⇒ Object
73 |
# File 'lib/odata_duty/schema_builder.rb', line 73 def entity_sets = all_containers |
#entity_types ⇒ Object
69 70 71 |
# File 'lib/odata_duty/schema_builder.rb', line 69 def entity_types all_types.grep(EntityType) end |
#enum_types ⇒ Object
61 62 63 |
# File 'lib/odata_duty/schema_builder.rb', line 61 def enum_types all_types.grep(EnumType) end |
#execute(url, context:, query_options: {}) ⇒ Object
83 84 85 |
# File 'lib/odata_duty/schema_builder.rb', line 83 def execute(url, context:, query_options: {}) Executor.execute(url: url, context: context, query_options: , schema: self) end |
#index_hash ⇒ Object
107 108 109 |
# File 'lib/odata_duty/schema_builder.rb', line 107 def index_hash EdmxSchema.index_hash(self) end |
#individual_entity_sets ⇒ Object
79 80 81 |
# File 'lib/odata_duty/schema_builder.rb', line 79 def individual_entity_sets entity_sets.select { |t| t.resolver_class.method_defined?(:individual) } end |
#inspect ⇒ Object
27 28 29 30 |
# File 'lib/odata_duty/schema_builder.rb', line 27 def inspect "#<#{self.class} @namespace=#{@namespace} @base_path=#{@base_path} \ containers=#{@containers.keys} types=#{@types.keys}>" end |
#metadata_xml ⇒ Object
103 104 105 |
# File 'lib/odata_duty/schema_builder.rb', line 103 def EdmxSchema.(self) end |
#to_mcp_server ⇒ Object
99 100 101 |
# File 'lib/odata_duty/schema_builder.rb', line 99 def to_mcp_server McpServerBuilder.build(self) end |