Module: Pathway::Plugins::SequelModels::InstanceMethods

Extended by:
Forwardable
Defined in:
lib/pathway/plugins/sequel_models.rb

Defined Under Namespace

Modules: Finder

Instance Method Summary collapse

Instance Method Details

#build_model_with(params) ⇒ Object



55
56
57
# File 'lib/pathway/plugins/sequel_models.rb', line 55

def build_model_with(params)
  wrap(model_class.new(params))
end

#fetch_model(state, from: model_class, key: field, column: field, overwrite: false) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/pathway/plugins/sequel_models.rb', line 46

def fetch_model(state, from: model_class, key: field, column: field, overwrite: false)
  if state[result_key].nil? || overwrite
    find_model_with(state[:input][key], from, column)
      .then { |model| state.update(result_key => model) }
  else
    state
  end
end

#find_model_with(key, dataset = model_class, column = field) ⇒ Object



59
60
61
# File 'lib/pathway/plugins/sequel_models.rb', line 59

def find_model_with(key, dataset = model_class, column = field)
  wrap_if_present(dataset.first(column => key))
end