Module: HashEngine::Actions

Includes:
Format
Included in:
HashEngine, Transform
Defined in:
lib/hash_engine/actions.rb

Constant Summary collapse

@@actions =
{}

Instance Method Summary collapse

Methods included from Format

#add_format, #format, #formats

Instance Method Details

#action(type, field_data, fetched_data) ⇒ Object



22
23
24
25
26
# File 'lib/hash_engine/actions.rb', line 22

def action(type, field_data, fetched_data)
  if valid_action?(type)
    actions[type].call(fetched_data, field_data)
  end
end

#actionsObject



10
11
12
# File 'lib/hash_engine/actions.rb', line 10

def actions
  @@actions
end

#add_action(name, &block) ⇒ Object



14
15
16
# File 'lib/hash_engine/actions.rb', line 14

def add_action name, &block
  @@actions[name] = block
end

#valid_action?(action) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/hash_engine/actions.rb', line 18

def valid_action?(action)
  actions.has_key?(action)
end