# File lib/o_data/abstract_schema/entity_type.rb, line 54 def primary_key_for(one) return nil if @key_property.blank? @key_property.value_for(one) end
class OData::AbstractSchema::EntityType
Attributes
key_property[R]
properties[RW]
Public Class Methods
new(schema, name)
click to toggle source
Calls superclass method
# File lib/o_data/abstract_schema/entity_type.rb, line 8 def initialize(schema, name) super(schema, name) @properties = [] @key_property = nil @navigation_properties = [] end
Public Instance Methods
Property(*args)
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 25 def Property(*args) property = Property.new(self.schema, self, *args) @properties << property property end
exists?(key_value)
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 46 def exists?(key_value) !!find_one(key_value) end
find_all(key_values = {})
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 37 def find_all(key_values = {}) [] end
find_one(key_value)
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 41 def find_one(key_value) return nil if @key_property.blank? find_all(@key_property => key_value).first end
href_for(one)
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 50 def href_for(one) collection_name + '(' + primary_key_for(one) + ')' end
inspect()
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 59 def inspect "#<< #{qualified_name.to_s}(#{[@properties, @navigation_properties].flatten.collect { |p| "#{p.name.to_s}: #{p.return_type.to_s}" }.join(', ')}) >>" end
key_property=(property)
click to toggle source
# File lib/o_data/abstract_schema/entity_type.rb, line 19 def key_property=(property) return nil unless property.is_a?(Property) return nil unless @properties.include?(property) @key_property = property end
primary_key_for(one)
click to toggle source