Module: Ros::Console::Methods
- Defined in:
- lib/ros/core/console.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.init ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ros/core/console.rb', line 41 def init models.each do |model| name = File.basename(model).gsub('.rb', '') id = name[0] define_method("#{id}a") { name.classify.constantize.all } define_method("#{id}c") { fbc(name) } define_method("#{id}f") { Rails.configuration.x.memoized_shortcuts["#{id}f"] ||= name.classify.constantize.first } define_method("#{id}l") { Rails.configuration.x.memoized_shortcuts["#{id}l"] ||= name.classify.constantize.last } define_method("#{id}p") { |column| name.classify.constantize.pluck(column) } end end |
Instance Method Details
#ct ⇒ Object
54 |
# File 'lib/ros/core/console.rb', line 54 def ct; Rails.configuration.x.memoized_shortcuts[:ct] ||= Tenant.find_by(schema_name: Apartment::Tenant.current) end |
#fbc(type) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ros/core/console.rb', line 29 def fbc(type) try_count ||= 0 FactoryBot.create(type) rescue KeyError try_count += 1 Dir[Pathname.new(Dir.pwd).join('spec', 'factories', '**', '*.rb')].each { |f| require f } retry if try_count < 2 end |
#models ⇒ Object
38 39 40 |
# File 'lib/ros/core/console.rb', line 38 def models Dir[Pathname.new(Dir.pwd).join('app', 'models', '**', '*.rb')] end |