Module: OData

Defined in:
lib/odata.rb,
lib/odata/type.rb,
lib/odata/errors.rb,
lib/odata/request.rb,
lib/odata/service.rb,
lib/odata/property.rb,
lib/odata/operation.rb,
lib/odata/singleton.rb,
lib/odata/entity_set.rb,
lib/odata/types/enum_type.rb,
lib/odata/types/entity_type.rb,
lib/odata/types/complex_type.rb,
lib/odata/navigation_property.rb,
lib/odata/types/primitive_type.rb,
lib/odata/types/collection_type.rb,
lib/odata/types/primitive_types/date_type.rb,
lib/odata/types/primitive_types/guid_type.rb,
lib/odata/types/primitive_types/binary_type.rb,
lib/odata/types/primitive_types/double_type.rb,
lib/odata/types/primitive_types/int_16_type.rb,
lib/odata/types/primitive_types/int_32_type.rb,
lib/odata/types/primitive_types/int_64_type.rb,
lib/odata/types/primitive_types/stream_type.rb,
lib/odata/types/primitive_types/string_type.rb,
lib/odata/types/primitive_types/boolean_type.rb,
lib/odata/types/primitive_types/date_time_offset_type.rb

Defined Under Namespace

Classes: AuthenticationError, AuthorizationError, BinaryType, BooleanType, ClientError, CollectionType, ComplexType, DateTimeOffsetType, DateType, DoubleType, EntitySet, EntityType, EnumType, Error, GuidType, HTTPError, Int16Type, Int32Type, Int64Type, NavigationProperty, Operation, PrimitiveType, Property, Request, ServerError, Service, Singleton, StreamType, StringType, Type

Class Method Summary collapse

Class Method Details

.convert_keys_to_camel_case(properties) ⇒ Object


36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/odata.rb', line 36

def self.convert_keys_to_camel_case(properties)
  if properties.respond_to? :keys
    results = {}
    properties.each do |key, value|
      results[convert_to_camel_case(key)] = convert_keys_to_camel_case(value)
    end
    results
  elsif properties.is_a? Array
    properties.map { |m| convert_keys_to_camel_case(m) }
  else
    properties
  end
end

.convert_keys_to_snake_case(properties) ⇒ Object


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/odata.rb', line 24

def self.convert_keys_to_snake_case(properties)
  if properties.respond_to? :keys
    results = {}
    properties.each do |key, value|
      results[convert_to_snake_case(key)] = convert_keys_to_snake_case(value)
    end
    results
  else
    properties
  end
end

.convert_to_camel_case(str) ⇒ Object


18
19
20
21
22
# File 'lib/odata.rb', line 18

def self.convert_to_camel_case(str)
  first_letter, rest = str.to_s.split("", 2)
  cameled_rest = rest.gsub(/_(.)/) { |l| l[1].upcase }
  first_letter.downcase.concat(cameled_rest)
end

.convert_to_snake_case(str) ⇒ Object


13
14
15
16
# File 'lib/odata.rb', line 13

def self.convert_to_snake_case(str)
  first_letter, rest = str.to_s.split("", 2)
  "#{first_letter}#{rest.to_s.gsub(/([A-Z])/, '_\1')}".downcase
end