module NStore

Mixin module to include into your class @example

class YourClass
  include NStore

  attr_accessor :meta

  nstore :meta,
         accessors: {
             jira: {
                 board: [:id, :name, user: %i[id name]]
             },
             trello: %i[id name]
         },
         prefix:       false,
         stringify:    true
  ...

Constants

VERSION

Public Class Methods

included(klass) click to toggle source
# File lib/nstore.rb, line 25
def self.included(klass)
  klass.extend(ClassMethods)
end

Public Instance Methods

read_nstore_attribute(attribute, keys) click to toggle source

@param [Symbol,String] attribute @param [Array<String,Symbol>] keys @return [Object]

# File lib/nstore.rb, line 101
def read_nstore_attribute(attribute, keys)
  send(attribute).send(:dig, *keys)
end
write_nstore_attribute(attribute, keys, value) click to toggle source

@param [Symbol,String] attribute @param [Array<String,Symbol>] keys @param [Object] value

# File lib/nstore.rb, line 87
def write_nstore_attribute(attribute, keys, value)
  send("#{attribute}=", {}) if send(attribute).nil?
  position = send(attribute)

  keys[0..-2].each do |key|
    position[key] = {} unless position[key].is_a? Hash
    position      = position[key]
  end
  position[keys[-1]] = value
end