Module: Qdocs::Helpers
- Included in:
- Base::Const, Base::Method
- Defined in:
- lib/qdocs.rb
Instance Method Summary collapse
- #find_constant(const) ⇒ Object
- #own_methods(methods) ⇒ Object
- #params_to_hash(params) ⇒ Object
- #render_response(const, type, attrs) ⇒ Object
- #source_location_to_str(source_location) ⇒ Object
Instance Method Details
#find_constant(const) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/qdocs.rb', line 35 def find_constant(const) case const when Symbol, String Object.const_get const else const end rescue NameError raise UnknownClassError, "Unknown constant #{const}" end |
#own_methods(methods) ⇒ Object
23 24 25 |
# File 'lib/qdocs.rb', line 23 def own_methods(methods) methods - Object.methods end |
#params_to_hash(params) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/qdocs.rb', line 27 def params_to_hash(params) hsh = {} params.each_with_index do |prm, i| hsh[prm[1] || "unnamed_arg_#{i}"] = prm[0] end hsh end |
#render_response(const, type, attrs) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/qdocs.rb', line 46 def render_response(const, type, attrs) { original_input: @original_input, constant: { name: const.name, type: const.class.name, }, query_type: type, attributes: attrs, } end |
#source_location_to_str(source_location) ⇒ Object
17 18 19 20 21 |
# File 'lib/qdocs.rb', line 17 def source_location_to_str(source_location) if source_location && source_location.length == 2 "#{source_location[0]}:#{source_location[1]}" end end |