Sha256: 9e77c265c7398820d24b548cbcf3826fcc34e12326c3b3cd80f6a139d22839c3
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
module Columns # 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" class ModelData # Public: Get the String model's name. For a model `app/models/user.rb`, # the model's name will be `user`. attr_reader :name # Public: Get a String formatted content. attr_reader :content # Public: Creates a new ModelData. # # raw_data - A RawData object. 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
columns-0.1.1 | lib/columns/model_data.rb |
columns-0.1.0 | lib/columns/model_data.rb |