Sha256: 149be103da43a603174da7f6b33b7024776a8fb9fa403de03c7cdcca99748148
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
require 'inch/code_object/converter' module Inch module Codebase # An object that holds a code_object as well as it's evaluation # and exposes shortcut methods to the commonly asked members of # both. class Object extend Forwardable attr_reader :code_object # @return [String] attr_reader :language # @return [Grade] # when objects are assigned to GradeLists, this grade is set to # enable easier querying for objects of a certain grade attr_writer :grade # convenient shortcuts to evalution object def_delegators :evaluation, :score, :roles, :priority # convenient shortcuts to code object def_delegators :code_object, :object_lookup= # @param language [String,Symbol] # @param code_object [YARD::Object::Base] # @param object_lookup [Codebase::Objects] def initialize(language, code_object, object_lookup) @language = language @code_object = CodeObject::Proxy.for(language, code_object, object_lookup) end def evaluation @evaluation ||= Evaluation::Proxy.for(@language, self) end # @return [Grade] def grade @grade ||= Evaluation.new_grade_lists.find do |range| range.scores.include?(score) end.grade end def method_missing(name, *args, &block) if code_object.respond_to?(name) self.class.class_eval <<-RUBY def #{name}(*args, &block) code_object.#{name}(*args, &block) end RUBY code_object.send(name, *args, &block) else super end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inch-0.5.0.rc5 | lib/inch/codebase/object.rb |
inch-0.5.0.rc4 | lib/inch/codebase/object.rb |