Class: Schema2type::CovertService

Inherits:
Object
  • Object
show all
Defined in:
lib/schema2type/covert_service.rb

Defined Under Namespace

Modules: ActiveRecord

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(is_snake_case) ⇒ CovertService

Returns a new instance of CovertService.



3
4
5
6
# File 'lib/schema2type/covert_service.rb', line 3

def initialize(is_snake_case)
  @converted_types = []
  @is_snake_case = is_snake_case
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject



23
24
25
26
# File 'lib/schema2type/covert_service.rb', line 23

def method_missing(*)
  # To exclude unnecessary methods
  # TODO: add error handling
end

Class Method Details

.method_missingObject



28
29
30
31
# File 'lib/schema2type/covert_service.rb', line 28

def self.method_missing(*)
  # To exclude unnecessary methods
  # TODO: add error handling
end

Instance Method Details

#convert_schema_to_type(table_name) {|converter| ... } ⇒ Object Also known as: create_table

mock method for create_table in schema.rb

Yields:

  • (converter)


13
14
15
16
17
# File 'lib/schema2type/covert_service.rb', line 13

def convert_schema_to_type(table_name, *)
  converter = SchemaConverter.new(table_name: table_name, is_snake_case: @is_snake_case)
  yield converter
  @converted_types.concat converter.converted_type_lines
end

#get_bindingObject



8
9
10
# File 'lib/schema2type/covert_service.rb', line 8

def get_binding
  binding
end

#skip_dslObject Also known as: add_foreign_key



19
20
21
# File 'lib/schema2type/covert_service.rb', line 19

def skip_dsl(*)
  @converted_types
end