class Configurate::SettingPath

Class encapsulating the concept of a path to a setting

Public Class Methods

new(path=[]) click to toggle source
# File lib/configurate/setting_path.rb, line 11
def initialize path=[]
  path = path.split(".") if path.is_a? String
  @path = path
end

Public Instance Methods

==(other) click to toggle source
# File lib/configurate/setting_path.rb, line 67
def ==(other)
  to_s == other.to_s
end
action?() click to toggle source

Whether the current path looks like an action method

# File lib/configurate/setting_path.rb, line 34
def action?
  @path.last.to_s.end_with?("!")
end
each() { |clean_special_characters(component)| ... } click to toggle source
# File lib/configurate/setting_path.rb, line 43
def each
  return to_enum(:each) unless block_given?

  @path.each do |component|
    yield clean_special_characters(component)
  end
end
initialize_copy(original) click to toggle source
Calls superclass method
# File lib/configurate/setting_path.rb, line 16
def initialize_copy original
  super
  @path = @path.clone
end
inspect() click to toggle source
# File lib/configurate/setting_path.rb, line 71
def inspect
  "<SettingPath:#{object_id.to_s(16)} "\
  "path=#{self}:#{@path.object_id.to_s(16)} "\
  "question=#{question?} "\
  "action=#{action?} "\
  "setter=#{setter?}>"
end
question?() click to toggle source

Whether the current path looks like a question method

# File lib/configurate/setting_path.rb, line 29
def question?
  @path.last.to_s.end_with?("?")
end
question_action_or_setter?() click to toggle source

Whether the current path looks like a question or setter method

# File lib/configurate/setting_path.rb, line 24
def question_action_or_setter?
  question? || action? || setter?
end
setter?() click to toggle source

Whether the current path looks like a setter method

# File lib/configurate/setting_path.rb, line 39
def setter?
  @path.last.to_s.end_with?("=")
end
to_s() click to toggle source
# File lib/configurate/setting_path.rb, line 63
def to_s
  join(".")
end

Private Instance Methods

clean_special_characters(value) click to toggle source
# File lib/configurate/setting_path.rb, line 81
def clean_special_characters value
  value.to_s.chomp("?").chomp("=")
end