Class: RbsActiverecord::Model

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rbs_activerecord/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Model

Returns a new instance of Model.



20
21
22
# File 'lib/rbs_activerecord/model.rb', line 20

def initialize(klass) #: void
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

: singleton(ActiveRecord::Base)



9
10
11
# File 'lib/rbs_activerecord/model.rb', line 9

def klass
  @klass
end

Instance Method Details

#filenameObject

: String



24
25
26
# File 'lib/rbs_activerecord/model.rb', line 24

def filename #: String
  "app/models/#{klass.name.to_s.underscore}.rb"
end

#parentsObject

: Array



28
29
30
31
# File 'lib/rbs_activerecord/model.rb', line 28

def parents #: Array[singleton(ActiveRecord::Base)]
  ancestors = klass.ancestors #: Array[singleton(ActiveRecord::Base)]
  ancestors.select { |cls| cls < ActiveRecord::Base && cls != klass && !cls.abstract_class? }
end