Class: ActiveRecordSchemaScrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_schema_scrapper.rb,
lib/active_record_schema_scrapper/version.rb,
lib/active_record_schema_scrapper/attribute.rb,
lib/active_record_schema_scrapper/attributes.rb,
lib/active_record_schema_scrapper/association.rb,
lib/active_record_schema_scrapper/associations.rb,
lib/active_record_schema_scrapper/object_error.rb

Defined Under Namespace

Classes: Association, Associations, Attribute, Attributes, ErrorObject, UnregisteredType

Constant Summary collapse

VERSION =
"0.9.0".freeze

Instance Method Summary collapse

Constructor Details

#initialize(model:, association_opts: {}, attribute_opts: {}) ⇒ ActiveRecordSchemaScrapper

Returns a new instance of ActiveRecordSchemaScrapper.



9
10
11
12
13
# File 'lib/active_record_schema_scrapper.rb', line 9

def initialize(model:, association_opts: {}, attribute_opts: {})
  @model            = model
  @association_opts = association_opts.merge(model: model)
  @attribute_opts   = attribute_opts.merge(model: model)
end

Instance Method Details

#abstract_class?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/active_record_schema_scrapper.rb', line 27

def abstract_class?
  !!model.abstract_class?
end

#associationsObject



15
16
17
# File 'lib/active_record_schema_scrapper.rb', line 15

def associations
  @associations ||= Associations.new(association_opts)
end

#attributesObject



19
20
21
# File 'lib/active_record_schema_scrapper.rb', line 19

def attributes
  @attributes ||= Attributes.new(attribute_opts)
end

#table_nameObject



23
24
25
# File 'lib/active_record_schema_scrapper.rb', line 23

def table_name
  model.table_name
end