Module: Crabfarm::Assertion::Fields

Includes:
Context
Included in:
BaseReducer, BaseStruct
Defined in:
lib/crabfarm/assertion/fields.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Context

#assert

Class Method Details

.included(klass) ⇒ Object



65
66
67
# File 'lib/crabfarm/assertion/fields.rb', line 65

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#field_hashObject



79
80
81
# File 'lib/crabfarm/assertion/fields.rb', line 79

def field_hash
  @field_hash
end

#reset_fieldsObject



69
70
71
72
73
74
75
76
77
# File 'lib/crabfarm/assertion/fields.rb', line 69

def reset_fields
  klass = self.class

  @field_hash = {}
  klass.fields.each do |field|
    value = klass.field_defaults[field]
    @field_hash[field] = value.duplicable? ? value.clone : value
  end
end