Class: ActiveRecordSchemaScrapper::Attributes
- Inherits:
-
Object
- Object
- ActiveRecordSchemaScrapper::Attributes
- Includes:
- Enumerable
- Defined in:
- lib/active_record_schema_scrapper/attributes.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
- .register_default(name:, klass:, cast_type: nil, type: nil) ⇒ Object
- .register_type(name:, klass:, cast_type: nil) ⇒ Object
- .registered_defaults ⇒ Object
- .registered_types ⇒ Object
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(model:) ⇒ Attributes
constructor
A new instance of Attributes.
- #to_a ⇒ Object
Constructor Details
#initialize(model:) ⇒ Attributes
Returns a new instance of Attributes.
32 33 34 35 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 32 def initialize(model:) @model = model @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
29 30 31 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 29 def errors @errors end |
Class Method Details
.register_default(name:, klass:, cast_type: nil, type: nil) ⇒ Object
20 21 22 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 20 def register_default(name:, klass:, cast_type: nil, type: nil) registered_defaults << [name, klass, cast_type, type] end |
.register_type(name:, klass:, cast_type: nil) ⇒ Object
8 9 10 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 8 def register_type(name:, klass:, cast_type: nil) registered_types << [name, klass, cast_type] end |
.registered_defaults ⇒ Object
24 25 26 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 24 def registered_defaults @registered_defaults ||= [] end |
.registered_types ⇒ Object
12 13 14 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 12 def registered_types @registered_types ||= [] end |
Instance Method Details
#each ⇒ Object
39 40 41 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 39 def each call.each { |attr| yield(attr) } end |
#to_a ⇒ Object
43 44 45 |
# File 'lib/active_record_schema_scrapper/attributes.rb', line 43 def to_a @to_a ||= map { |v| v } end |