Class: OdataDuty::Schema::Metadata
- Inherits:
-
Object
- Object
- OdataDuty::Schema::Metadata
- Defined in:
- lib/odata_duty.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #check_names ⇒ Object
- #complex_types ⇒ Object
- #endpoints ⇒ Object
- #entity_sets ⇒ Object
- #entity_types ⇒ Object
- #enum_types ⇒ Object
-
#initialize(schema) ⇒ Metadata
constructor
A new instance of Metadata.
- #metadata_types ⇒ Object
- #namespace ⇒ Object
- #title ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(schema) ⇒ Metadata
Returns a new instance of Metadata.
222 223 224 |
# File 'lib/odata_duty.rb', line 222 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
220 221 222 |
# File 'lib/odata_duty.rb', line 220 def schema @schema end |
Instance Method Details
#check_names ⇒ Object
257 258 259 260 261 262 263 264 |
# File 'lib/odata_duty.rb', line 257 def check_names names = Set.new (enum_types + complex_types + entity_types).each do |et| raise "Duplicate #{et.name} type" if names.include?(et.name) names << et.name end end |
#complex_types ⇒ Object
245 246 247 |
# File 'lib/odata_duty.rb', line 245 def complex_types .select { |mt| mt. == :complex } end |
#endpoints ⇒ Object
253 254 255 |
# File 'lib/odata_duty.rb', line 253 def endpoints entity_sets end |
#entity_sets ⇒ Object
233 234 235 |
# File 'lib/odata_duty.rb', line 233 def entity_sets schema.entity_sets.map(&:__metadata) end |
#entity_types ⇒ Object
241 242 243 |
# File 'lib/odata_duty.rb', line 241 def entity_types .select { |mt| mt. == :entity } end |
#enum_types ⇒ Object
249 250 251 |
# File 'lib/odata_duty.rb', line 249 def enum_types .select { |mt| mt. == :enum } end |
#metadata_types ⇒ Object
237 238 239 |
# File 'lib/odata_duty.rb', line 237 def @metadata_types ||= entity_sets.flat_map(&:metadata_types).uniq.map(&:__metadata) end |
#namespace ⇒ Object
229 230 231 |
# File 'lib/odata_duty.rb', line 229 def namespace schema.namespace end |
#title ⇒ Object
227 |
# File 'lib/odata_duty.rb', line 227 def title = schema.title |
#version ⇒ Object
226 |
# File 'lib/odata_duty.rb', line 226 def version = schema.version |