Class: OData::AbstractSchema::End
- Inherits:
-
SchemaObject
- Object
- SchemaObject
- OData::AbstractSchema::End
- Defined in:
- lib/o_data/abstract_schema/end.rb
Constant Summary collapse
- @@end_option_names =
%w{nullable multiple polymorphic}
Instance Attribute Summary collapse
-
#association ⇒ Object
readonly
Returns the value of attribute association.
-
#entity_type ⇒ Object
readonly
Returns the value of attribute entity_type.
-
#options ⇒ Object
Returns the value of attribute options.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
Attributes inherited from SchemaObject
Instance Method Summary collapse
-
#initialize(schema, association, entity_type, return_type, name, options = {}) ⇒ End
constructor
A new instance of End.
- #inspect ⇒ Object
-
#to_multiplicity ⇒ Object
def return_type @options ? ‘Collection(’ + @return_type.to_s + ‘)’ : @return_type.to_s end.
Methods inherited from SchemaObject
#<=>, #plural_name, #qualified_name, #singular_name
Methods included from Comparable
Constructor Details
#initialize(schema, association, entity_type, return_type, name, options = {}) ⇒ End
Returns a new instance of End.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/o_data/abstract_schema/end.rb', line 17 def initialize(schema, association, entity_type, return_type, name, = {}) super(schema, name) @association = association @entity_type = entity_type @return_type = return_type unless @entity_type.nil? @return_type ||= @entity_type.qualified_name end @options = {} .keys.select { |key| @@end_option_names.include?(key.to_s) }.each do |key| @options[key.to_sym] = [key] end end |
Instance Attribute Details
#association ⇒ Object (readonly)
Returns the value of attribute association.
13 14 15 |
# File 'lib/o_data/abstract_schema/end.rb', line 13 def association @association end |
#entity_type ⇒ Object (readonly)
Returns the value of attribute entity_type.
14 15 16 |
# File 'lib/o_data/abstract_schema/end.rb', line 14 def entity_type @entity_type end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/o_data/abstract_schema/end.rb', line 15 def @options end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
14 15 16 |
# File 'lib/o_data/abstract_schema/end.rb', line 14 def return_type @return_type end |
Instance Method Details
#inspect ⇒ Object
45 46 47 |
# File 'lib/o_data/abstract_schema/end.rb', line 45 def inspect "#<< #{qualified_name.to_s}(return_type: #{@return_type.to_s}, to_multiplicity: #{to_multiplicity.to_s}) >>" end |
#to_multiplicity ⇒ Object
def return_type
@options[:multiple] ? 'Collection(' + @return_type.to_s + ')' : @return_type.to_s
end
38 39 40 41 42 43 |
# File 'lib/o_data/abstract_schema/end.rb', line 38 def to_multiplicity m = (@options[:nullable] ? '0' : '1') + '..' + (@options[:multiple] ? '*' : '1') m = '1' if m == '1..1' m = '*' if m == '0..*' m end |