Sha256: ebb332fec82efc3d94123a7e02d0eaafe8a3975344ecbcb73c06f4af82f19fe9
Contents?: true
Size: 987 Bytes
Versions: 37
Compression:
Stored size: 987 Bytes
Contents
module FactoryGirl # @api private class DeclarationList include Enumerable def initialize(name = nil) @declarations = [] @name = name @overridable = false end def declare_attribute(declaration) delete_declaration(declaration) if overridable? @declarations << declaration declaration end def overridable @overridable = true end def attributes @attributes ||= AttributeList.new(@name).tap do |list| to_attributes.each do |attribute| list.define_attribute(attribute) end end end def each(&block) @declarations.each(&block) end private def delete_declaration(declaration) @declarations.delete_if {|decl| decl.name == declaration.name } end def to_attributes @declarations.inject([]) {|result, declaration| result += declaration.to_attributes } end def overridable? @overridable end end end
Version data entries
37 entries across 28 versions & 4 rubygems