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


5
6
7
# File 'lib/diaspora_federation/test/entity_generator.rb', line 5

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

Instance Method Details

#build_instanceObject


9
10
11
# File 'lib/diaspora_federation/test/entity_generator.rb', line 9

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

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


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

def to_hash(attributes=[], _callbacks=[])
  process_attributes(attributes)
  _attributes.each_with_object({}) do |(name, value), hash|
    hash[name.to_sym] = value
  end
end