Module: Assertion::DSL::Attributes

Included in:
Base
Defined in:
lib/assertion/dsl/attributes.rb

Overview

Allows adding aliases to values of the ‘#attributes` hash.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



34
35
36
# File 'lib/assertion/dsl/attributes.rb', line 34

def self.extended(klass)
  klass.__send__(:define_method, :attributes) { @attributes ||= {} }
end

Instance Method Details

#attribute(*names) ⇒ undefined

Declares new attribute(s) by name(s)

Parameters:

  • names (#to_sym, Array<#to_sym>)

Returns:

  • (undefined)

Raises:

  • (NameError)

    When a given name is either used by instance methods, or reserved by the ‘#check` method to be implemented later.



29
30
31
# File 'lib/assertion/dsl/attributes.rb', line 29

def attribute(*names)
  names.flatten.map(&:to_sym).each(&method(:__add_attribute__))
end

#attributesArray<Symbol>

List of declared attributes

Returns:

  • (Array<Symbol>)


15
16
17
# File 'lib/assertion/dsl/attributes.rb', line 15

def attributes
  @attributes ||= []
end