class YARD::Dizby::ConfigAccessHandler
Public Instance Methods
access_permissions()
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 12 def access_permissions case statement.method_name(true) when :config_reader [true, false] when :config_writer [false, true] when :config_accessor [true, true] else [false, false] end end
process()
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 84 def process return if statement.type == :var_ref || statement.type == :vcall params = statement.parameters(false).dup validated_attribute_names(params).each do |name| process_access(name) end end
process_access(name)
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 76 def process_access(name) read, write = access_permissions namespace.attributes[scope][name] ||= SymbolHash[read: nil, write: nil] process_reader(name, read) process_writer(name, write) end
process_impl(method, permission) { |obj| ... }
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 25 def process_impl(method, permission) if permission obj = MethodObject.new(namespace, method, scope) yield obj register(obj) obj else namespace.children.find do |o| o.name == method.to_sym && o.scope == scope end end end
process_reader(attribute, permission)
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 48 def process_reader(attribute, permission) final = process_impl(attribute, permission) do |obj| signature(obj, "def #{attribute}", " @config[:#{attribute}]\nend") if obj.docstring.blank?(false) obj.docstring = "Returns the value of configuration attribute #{attribute}" end end store_obj :read, attribute, final end
process_writer(attribute, permission)
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 61 def process_writer(attribute, permission) final = process_impl("#{attribute}=", permission) do |obj| obj.parameters = [['value', nil]] signature(obj, "def #{attribute}=(value)", " @config[:#{attribute}] = value\nend") obj.docstring = <<-eos if obj.docstring.blank?(false) Sets the configuration attribute #{attribute} @param value the value to set the attribute #{attribute} to. eos end store_obj :write, attribute, final end
signature(obj, sig, src)
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 43 def signature(obj, sig, src) obj.signature ||= sig obj.source ||= "#{sig}\n#{src}" end
store_obj(type, name, obj)
click to toggle source
# File lib/yard_dizby/config_access_handler.rb, line 39 def store_obj(type, name, obj) namespace.attributes[scope][name][type] = obj if obj end