class Me::Mappers::GitConfigStore2

Attributes

email[R]
fetched[R]
identity_name[R]
name[R]

Public Class Methods

find_by_identity(identity_name) click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 7
def self.find_by_identity(identity_name)
  new(nil, nil, identity_name).find
end
new(name, email, identity_name) click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 11
def initialize(name, email, identity_name)
  @identity_name = identity_name
  @name = name || fetch_name
  @email = email || fetch_email
end

Public Instance Methods

find() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 17
def find
  ensure_present
  GitConfig
    .new(name, email, identity_name)
    .with_mapper(self)
end
update(name: nil, email: nil) click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 24
def update(name: nil, email: nil)
  return unless name || email
  scoped.set("name", name) if name
  scoped.set("email", email) if email
  scoped.save
end

Private Instance Methods

_scoped() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 56
def _scoped
  store.get_or_set("identities", {})
  store.get_or_set("identities", identity_name, {})
  store.get_or_set("identities", identity_name, "git", {})
  store.scoped("identities", identity_name, "git")
end
ensure_present() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 35
def ensure_present
  return if name && email
  fail Errors::GitNotConfigured, identity_name
end
fetch_email() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 44
def fetch_email
  scoped.fetch("email") { nil }
end
fetch_name() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 40
def fetch_name
  scoped.fetch("name") { nil }
end
scoped() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 52
def scoped
  @_scoped ||= _scoped
end
store() click to toggle source
# File lib/me/mappers/git_config_store2.rb, line 48
def store
  @_store ||= Store.build
end