Class: Model
- Inherits:
-
Object
- Object
- Model
- Defined in:
- lib/atchu/model.rb
Instance Attribute Summary collapse
-
#table_name ⇒ Object
Returns the value of attribute table_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#table_name ⇒ Object
Returns the value of attribute table_name.
5 6 7 |
# File 'lib/atchu/model.rb', line 5 def table_name @table_name end |
Class Method Details
.for_table(table_name) ⇒ Object
7 8 9 10 11 |
# File 'lib/atchu/model.rb', line 7 def self.for_table table_name model = Model.new model.table_name = table_name model end |
Instance Method Details
#class_name ⇒ Object
13 14 15 |
# File 'lib/atchu/model.rb', line 13 def class_name table_name.classify end |
#file_name ⇒ Object
17 18 19 |
# File 'lib/atchu/model.rb', line 17 def file_name table_name.classify.underscore end |
#primary_key ⇒ Object
21 22 23 24 25 26 |
# File 'lib/atchu/model.rb', line 21 def primary_key query = Atchu::Queries.primary_key table_name keys = Atchu::Connection.get.select_all(query).rows return "" if keys.eql? [] keys.reduce(:+).map{|x|x.intern}.to_s.gsub("[","").gsub("]","") end |