Class: MegaScaffold::FieldsGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/mega_scaffold/fields_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ FieldsGenerator

Returns a new instance of FieldsGenerator.



5
6
7
# File 'lib/mega_scaffold/fields_generator.rb', line 5

def initialize(model)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/mega_scaffold/fields_generator.rb', line 3

def model
  @model
end

Instance Method Details

#generateObject



9
10
11
12
13
14
15
16
# File 'lib/mega_scaffold/fields_generator.rb', line 9

def generate
  model.columns.map do |e|
    {
      name: e.name,
      type: MegaScaffold::TypeDetector.find_type(e),
    }
  end
end