Skip to content

Commit

Permalink
attach_dsl: some examples about metadsl
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Andreev committed Apr 30, 2008
1 parent 71738cf commit f5a9337
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/strokedb/util/attach_dsl.rb
Expand Up @@ -24,10 +24,21 @@ def dsl
end

if $0 == __FILE__

module MetaDSL
def on_initialize(&block)
store_dsl_options("on_initialize", block)
end
end

module HasMany
attach_dsl MetaDSL
def has_many(*args)
store_dsl_options("has_many", args)
puts "has_many defined."
store_dsl_options("has_many", { :module => HasMany, :args => args } )
puts "has_many defined in #{self.inspect}"
end
on_initialize do |doc|
blah_blah
end
end

Expand All @@ -38,6 +49,7 @@ module App1
end

p App1.dsl
p App1.dsl["has_many"][:module].dsl

end

Expand Down

0 comments on commit f5a9337

Please sign in to comment.