Class: Eancom::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/eancom/definition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, &block) ⇒ Definition

Returns a new instance of Definition.



11
12
13
14
15
# File 'lib/eancom/definition.rb', line 11

def initialize(name:, type:, &block)
  @name = name
  @type = type
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/eancom/definition.rb', line 4

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/eancom/definition.rb', line 4

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/eancom/definition.rb', line 4

def type
  @type
end

Class Method Details

.create(name:, type:, &block) ⇒ Object



6
7
8
9
# File 'lib/eancom/definition.rb', line 6

def self.create(name:, type:, &block)
  definition = new(name: name, type: type, &block)
  Eancom.register_definition(definition)
end

Instance Method Details

#run(document:, config:) ⇒ Object



17
18
19
# File 'lib/eancom/definition.rb', line 17

def run(document:, config:)
  @block.call(document, config)
end