Module: RubyCodeAPI::Query
- Included in:
- Ruby::Node
- Defined in:
- lib/query/find.rb
Defined Under Namespace
Classes: FindError
Constant Summary collapse
- NODES =
Use this to generate all methods except for find_block which is a bit special
{ :module => Ruby::Module, :class => Ruby::Class, :variable => [Ruby::Variable, :token], :assignment => [Ruby::Assignment, :left_token], :call => Ruby::Call, :def => Ruby::Method }
Instance Method Summary collapse
- #find(type, name, options = {}, &block) ⇒ Object
- #find_block(name, options = {}) ⇒ Object
- #find_by(key, type, name, options) ⇒ Object
- #inside(type, name, options = {}, &block) ⇒ Object
Instance Method Details
#find(type, name, options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/query/find.rb', line 18 def find(type, name, = {}, &block) s = send :"find_#{type.to_s}", name, s.extend([:extend]) if [:extend] if block_given? block.arity < 1 ? s.instance_eval(&block) : block.call(s) else s end end |
#find_block(name, options = {}) ⇒ Object
53 54 55 56 |
# File 'lib/query/find.rb', line 53 def find_block(name, = {}) .merge!(:block => true) if !.has_key?(:block_params) find_by(:identifier, Ruby::Call, name, ) end |
#find_by(key, type, name, options) ⇒ Object
48 49 50 51 |
# File 'lib/query/find.rb', line 48 def find_by(key, type, name, ) .merge!(key => name) get_obj.select(type, ).first end |
#inside(type, name, options = {}, &block) ⇒ Object
28 29 30 31 |
# File 'lib/query/find.rb', line 28 def inside(type, name, = {}, &block) raise FindError, "Must have block argument" if !block_given? find(type, name, = {}, &block) end |