Class: Geert::Model
- Inherits:
-
Object
- Object
- Geert::Model
- Defined in:
- lib/geert/model.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #associations ⇒ Object
- #columns_hash(*args) ⇒ Object
-
#initialize(model) ⇒ Model
constructor
A new instance of Model.
- #migration ⇒ Object
- #output ⇒ Object
- #table_name ⇒ Object
- #usable? ⇒ Boolean
Constructor Details
#initialize(model) ⇒ Model
Returns a new instance of Model.
7 8 9 |
# File 'lib/geert/model.rb', line 7 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/geert/model.rb', line 5 def model @model end |
Instance Method Details
#associations ⇒ Object
23 24 25 |
# File 'lib/geert/model.rb', line 23 def associations @associations ||= reflections.map { |reflection| Association.new(reflection, self) } end |
#columns_hash(*args) ⇒ Object
31 32 33 |
# File 'lib/geert/model.rb', line 31 def columns_hash(*args) model.columns_hash(*args) end |
#migration ⇒ Object
19 20 21 |
# File 'lib/geert/model.rb', line 19 def migration associations.map(&:migration).compact.sort if usable? end |
#output ⇒ Object
15 16 17 |
# File 'lib/geert/model.rb', line 15 def output output_string if usable? && association_output.any? end |
#table_name ⇒ Object
27 28 29 |
# File 'lib/geert/model.rb', line 27 def table_name model.table_name end |
#usable? ⇒ Boolean
11 12 13 |
# File 'lib/geert/model.rb', line 11 def usable? activerecord? && reflections.any? end |