Class: DiasporaFederation::Test::EntityGenerator

Inherits:
Fabrication::Generator::Base
  • Object
show all
Defined in:
lib/diaspora_federation/test/entity_generator.rb

Overview

Generator to instantiate entities

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.supports?(klass) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/diaspora_federation/test/entity_generator.rb', line 7

def self.supports?(klass)
  klass.ancestors.include?(DiasporaFederation::Entity)
end

Instance Method Details

#build_instanceObject



11
12
13
# File 'lib/diaspora_federation/test/entity_generator.rb', line 11

def build_instance
  self._instance = resolved_class.new(_attributes)
end

#to_hash(attributes = [], _callbacks = []) ⇒ Object



15
16
17
18
# File 'lib/diaspora_federation/test/entity_generator.rb', line 15

def to_hash(attributes=[], _callbacks=[])
  process_attributes(attributes)
  _attributes.transform_keys(&:to_sym)
end