Sha256: 07a1598ccf1f6ddd63d55445074f3b3d2f62de9e5929afcf6803cf6dfe0c4f59

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

module Immutabler
  class TypeMapper
    TYPE_MAPPING = {
      'int' => {
        type: 'NSInteger',
        is_ref: false,
        ref_type: 'assign',
        name_prefix: ''
      },
      'float' => {
        type: 'CGFloat',
        is_ref: false,
        ref_type: 'assign',
        name_prefix: ''
      },
      'bool' => {
        type: 'BOOL',
        is_ref: false,
        ref_type: 'assign',
        name_prefix: ''
      },
      'array' => {
        type: 'NSArray',
        is_ref: true,
        ref_type: 'strong',
        name_prefix: '*'
      },
      'string' => {
        type: 'NSString',
        is_ref: true,
        ref_type: 'strong',
        name_prefix: '*'
      },
      'dict' => {
        type: 'NSDictionary',
        is_ref: true,
        ref_type: 'strong',
        name_prefix: '*',
      },
      'id' => {
        type: 'id',
        is_ref: true,
        ref_type: 'strong',
        name_prefix: ''
      }
    }

    def self.map(type, options)
      TYPE_MAPPING.fetch(type, default_mapping(type)).merge(options)
    end

    private

    def self.default_mapping(type)
      {
        type: type,
        is_ref: true,
        ref_type: 'strong',
        name_prefix: '*'
      }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
immutabler-0.1.9 lib/immutabler/type_mapper.rb
immutabler-0.1.8 lib/immutabler/type_mapper.rb
immutabler-0.1.7 lib/immutabler/type_mapper.rb
immutabler-0.1.6 lib/immutabler/type_mapper.rb
immutabler-0.1.5 lib/immutabler/type_mapper.rb
immutabler-0.1.4 lib/immutabler/type_mapper.rb
immutabler-0.1.3 lib/immutabler/type_mapper.rb
immutabler-0.1.2 lib/immutabler/type_mapper.rb
immutabler-0.1.1 lib/immutabler/type_mapper.rb
immutabler-0.1.0 lib/immutabler/type_mapper.rb