-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Semyonov
committed
Oct 8, 2010
1 parent
3c1f028
commit 2f88c4e
Showing
5 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
module Yard | ||
module Mongoid | ||
# Your code goes here... | ||
end | ||
end | ||
require 'yard/mongoid' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module YARD | ||
module Mongoid | ||
autoload :VERSION, 'lib/mongoid/version' | ||
autoload :Extensions, 'lib/mongoid/extensions' | ||
end | ||
end | ||
|
||
require 'lib/mongoid/field_handler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module YARD | ||
module Mongoid | ||
module Extensions | ||
protected | ||
def effected_namespace | ||
if statement.type == :command_call | ||
context = statement.jump(:var_ref) | ||
|
||
unless context.source == 'self' | ||
return ensure_loaded!( | ||
Registry.resolve(namespace, context.source) | ||
) | ||
end | ||
end | ||
|
||
return namespace | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module YARD | ||
module Mongoid | ||
class FieldHandler < YARD::Handlers::Ruby::Base | ||
include Extensions | ||
|
||
handles method_call(:field) | ||
|
||
def process | ||
nobj = effected_namespace | ||
mscope = scope | ||
name = statement.parameters[0].last | ||
|
||
if name.type == :symbol | ||
name = name.source[1..-1] | ||
|
||
register MethodObject.new(nobj, name, mscope) do |o| | ||
o.visibility = :public | ||
o.source = statement.source | ||
o.signature = "def #{name}" | ||
end | ||
|
||
register MethodObject.new(nobj, "#{name}=", mscope) do |o| | ||
o.visibility = :public | ||
o.source = statement.source | ||
o.signature = "def #{name}=(value)" | ||
o.parameters = [['value', nil]] | ||
end | ||
|
||
register MethodObject.new(nobj, "#{name}?", mscope) do |o| | ||
o.visibility = :public | ||
o.source = statement.source | ||
o.signature = "def #{name}?" | ||
end | ||
|
||
register MethodObject.new(nobj, "#{name}?", mscope) do |o| | ||
o.visibility = :public | ||
o.source = statement.source | ||
o.signature = "def #{name}?" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.