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
- #description ⇒ 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.
206 207 208 |
# File 'lib/odata_duty.rb', line 206 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
204 205 206 |
# File 'lib/odata_duty.rb', line 204 def schema @schema end |
Instance Method Details
#check_names ⇒ Object
242 243 244 245 246 247 248 249 |
# File 'lib/odata_duty.rb', line 242 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
230 231 232 |
# File 'lib/odata_duty.rb', line 230 def complex_types .select { |mt| mt. == :complex } end |
#description ⇒ Object
212 |
# File 'lib/odata_duty.rb', line 212 def description = schema.description |
#endpoints ⇒ Object
238 239 240 |
# File 'lib/odata_duty.rb', line 238 def endpoints entity_sets end |
#entity_sets ⇒ Object
218 219 220 |
# File 'lib/odata_duty.rb', line 218 def entity_sets schema.entity_sets.map(&:__metadata) end |
#entity_types ⇒ Object
226 227 228 |
# File 'lib/odata_duty.rb', line 226 def entity_types .select { |mt| mt. == :entity } end |
#enum_types ⇒ Object
234 235 236 |
# File 'lib/odata_duty.rb', line 234 def enum_types .select { |mt| mt. == :enum } end |
#metadata_types ⇒ Object
222 223 224 |
# File 'lib/odata_duty.rb', line 222 def @metadata_types ||= entity_sets.flat_map(&:metadata_types).uniq.map(&:__metadata) end |
#namespace ⇒ Object
214 215 216 |
# File 'lib/odata_duty.rb', line 214 def namespace schema.namespace end |
#title ⇒ Object
211 |
# File 'lib/odata_duty.rb', line 211 def title = schema.title |
#version ⇒ Object
210 |
# File 'lib/odata_duty.rb', line 210 def version = schema.version |