Class: Columns::ModelData
- Inherits:
-
Object
- Object
- Columns::ModelData
- Defined in:
- lib/columns/model_data.rb
Overview
Public: 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
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Public: Get the model’s name.
Instance Method Summary collapse
-
#initialize(raw_data) ⇒ ModelData
constructor
A new instance of ModelData.
Constructor Details
#initialize(raw_data) ⇒ ModelData
Returns a new instance of ModelData.
29 30 31 32 33 34 35 36 37 |
# File 'lib/columns/model_data.rb', line 29 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)
Returns the value of attribute content.
27 28 29 |
# File 'lib/columns/model_data.rb', line 27 def content @content end |
#name ⇒ Object (readonly)
Public: Get the 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 |