lib/lookbook/source_inspector.rb in lookbook-1.0.8 vs lib/lookbook/source_inspector.rb in lookbook-1.1.0
- old
+ new
@@ -3,12 +3,13 @@
include Utils
attr_reader :code_object
delegate :groups, :source, to: :@code_object, allow_nil: true
- def initialize(code_object)
+ def initialize(code_object, eval_scope: nil)
@code_object = code_object
+ @eval_scope = eval_scope
end
def hidden?
@hidden ||= if code_object&.tag(:hidden)
code_object.tag(:hidden).text.strip != "false"
@@ -72,21 +73,26 @@
def parameter_defaults
@param_defaults ||= code_object&.parameters&.map { |str| Params.parse_method_param_str(str) }&.compact&.to_h
end
def params
- code_object&.tags("param")&.map do |param|
- Lookbook::Params.build_param(param, default: parameter_defaults[param.name])
+ @params ||= {}
+ @params[:param] ||= code_object&.tags("param")&.map do |param|
+ Lookbook::Params.build_param(param,
+ default: parameter_defaults[param.name],
+ eval_scope: @eval_scope)
end
end
def methods
@methods ||= code_object&.meths
end
def tags(name = nil)
tag_objects = code_object&.tags(name).presence || []
- Lookbook::Tags.process_tags(tag_objects)
+ Lookbook::Tags.process_tags(tag_objects,
+ eval_scope: @eval_scope,
+ file: (code_object.files.first[0] if code_object.files.any?))
end
def tag(name = nil)
tags(name).first
end