Class: Columns::ModelData
- Inherits:
-
Object
- Object
- Columns::ModelData
- Defined in:
- lib/columns/model_data.rb
Overview
Stores data about a model.
Model name
Usually a table is named with a plural, like ‘users’. The corresponding model name is in singular, like ‘user’.
Model content
We want a «ready to paste» content.
So, for example, if the raw content is:
integer "foo"
what we want is something like this:
# integer "foo"
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Public: Get a String formatted content.
-
#name ⇒ Object
readonly
Public: Get the String model’s name.
Instance Method Summary collapse
-
#initialize(raw_data) ⇒ ModelData
constructor
Public: Creates a new ModelData.
Constructor Details
#initialize(raw_data) ⇒ ModelData
Public: Creates a new ModelData.
raw_data - A RawData object.
33 34 35 36 37 38 39 40 41 |
# File 'lib/columns/model_data.rb', line 33 def initialize(raw_data) # Ok, this is really idiot, I know, I know. Must use inflectors in # the future. @name = raw_data.name[0...-1] contents = raw_data.content.split("\n") contents.map! {|line| "# #{line.gsub(/^\s*t\./, '')}\n" } @content = contents.join end |
Instance Attribute Details
#content ⇒ Object (readonly)
Public: Get a String formatted content.
28 29 30 |
# File 'lib/columns/model_data.rb', line 28 def content @content end |
#name ⇒ Object (readonly)
Public: Get the String model’s name. For a model ‘app/models/user.rb`, the model’s name will be ‘user`.
25 26 27 |
# File 'lib/columns/model_data.rb', line 25 def name @name end |