Module: Ansr::Model::ClassMethods
- Defined in:
- lib/ansr/model.rb
Defined Under Namespace
Classes: TypeProxy
Instance Method Summary collapse
- #build_default_scope ⇒ Object
- #column_types ⇒ Object
- #engine ⇒ Object
- #inherited(subclass) ⇒ Object
- #model ⇒ Object
- #references ⇒ Object
- #spawn ⇒ Object
- #table ⇒ Object
Instance Method Details
#build_default_scope ⇒ Object
47 48 49 |
# File 'lib/ansr/model.rb', line 47 def build_default_scope Ansr::Relation.new(model(), table()) end |
#column_types ⇒ Object
51 52 53 |
# File 'lib/ansr/model.rb', line 51 def column_types TypeProxy.new(table()) end |
#engine ⇒ Object
39 40 41 |
# File 'lib/ansr/model.rb', line 39 def engine model() end |
#inherited(subclass) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ansr/model.rb', line 10 def inherited(subclass) super # a hack for sanitize sql overrides to work, and some others where @klass used in place of klass() subclass.instance_variable_set("@klass", subclass) # a hack for the intermediate abstract model classes to work with table_name subclass.instance_variable_set("@table_name", subclass.name) end |
#model ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ansr/model.rb', line 18 def model m = begin instance_variable_get "@klass" end raise "#{name()}.model() -> nil" unless m m end |
#references ⇒ Object
26 27 28 |
# File 'lib/ansr/model.rb', line 26 def references [] end |
#spawn ⇒ Object
5 6 7 8 |
# File 'lib/ansr/model.rb', line 5 def spawn s = build_default_scope s.references!(references()) end |