Module: ActiveRecordParser

Included in:
AutoRspecGenerator
Defined in:
lib/auto_rspec/generators/auto_rspec/parsers/application_record_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse_active_record(the_class) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/auto_rspec/generators/auto_rspec/parsers/application_record_parser.rb', line 2

def parse_active_record(the_class)
  active_record_matchers = {}
  active_record_matchers[:relations] = parse_relations(the_class.reflect_on_all_associations)
  active_record_matchers[:nested_attributes] = the_class.nested_attributes_options
  active_record_matchers[:enums] = the_class.defined_enums
  active_record_matchers[:db_columns] = the_class.columns.map(&:name).drop(3)
  active_record_matchers[:db_indexes] = parse_db_indexes(the_class)
  active_record_matchers[:implicit_order_columns] = [the_class.implicit_order_column].flatten
  active_record_matchers[:readonly_attributes] = the_class.readonly_attributes

  active_record_matchers
end