Sha256: 735138dcb6c6cecd7b48186da925a6a1cea0a8f5f0d6e6d80a29b9c8e41a952d
Contents?: true
Size: 763 Bytes
Versions: 1
Compression:
Stored size: 763 Bytes
Contents
require_relative "./config" require_relative "./yaml_load" module Yamls class Parameters def initialize( params, model: nil, action: nil, required: nil, nested: [], filepath: "#{Rails.root}/#{Yamls::FILEPATH}" ) @params = params @required = required || model @nested = [model, action].push(*nested).compact.map(&:to_s) @filepath = filepath end def permit return params.permit(columns) if required.nil? params.require(required).permit(columns) end private attr_reader :params, :filepath, :required, :nested def yaml_loader @yaml_loader ||= YamlLoad.new(filepath) end def columns yaml_loader.load.dig(*nested) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yamls-0.1.0 | lib/yamls/parameters.rb |