class Table
Attributes
attributes[R]
name[R]
Public Class Methods
new(name, attributes)
click to toggle source
# File lib/active_hash_ext.rb, line 54 def initialize(name, attributes) @name, @attributes = name, attributes end
parse(table_data)
click to toggle source
# File lib/active_hash_ext.rb, line 63 def self.parse(table_data) return unless name = table_data[/table "(.+)"/] name = $1 atts = table_data.lines.to_a.select {|line| line =~ /t\.\w+/ }.map {|att| Attribute.parse att } Table.new(name, atts) end
Public Instance Methods
to_script(target)
click to toggle source
# File lib/active_hash_ext.rb, line 58 def to_script(target) return "rails generate #{target} #{modelize name} #{attributes.map(&:to_script).reject{|x| x.nil? || x.empty?}.join(' ')}" if target == "scaffold" return "rails generate #{target} #{modelize name} #{attributes.map(&:to_script).reject{|x| x.nil? || x.empty?}.join(' ')}" if target == "factory_girl:model" end
Private Instance Methods
modelize(string)
click to toggle source
# File lib/active_hash_ext.rb, line 71 def modelize (string) string.camelize.singularize end