Class: Leftovers::ConfigLoader::InheritSchemaAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/leftovers/config_loader/inherit_schema_attributes.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema, require_group: true, except: nil) ⇒ InheritSchemaAttributes

Returns a new instance of InheritSchemaAttributes.



6
7
8
9
10
# File 'lib/leftovers/config_loader/inherit_schema_attributes.rb', line 6

def initialize(schema, require_group: true, except: nil)
  @schema = schema
  @use_require_groups = require_group
  @except = Array(except)
end

Instance Method Details

#attributesObject



12
13
14
15
16
17
18
19
# File 'lib/leftovers/config_loader/inherit_schema_attributes.rb', line 12

def attributes
  @schema.attributes.map do |attr|
    next if @except.include?(attr.name)
    next attr.without_require_group unless @use_require_groups

    attr
  end.compact
end