Class: Markaby::CssProxy
Instance Method Summary collapse
-
#initialize(opts = {}, &blk) ⇒ CssProxy
constructor
A new instance of CssProxy.
- #method_missing(id_or_class, *args, &blk) ⇒ Object
Constructor Details
#initialize(opts = {}, &blk) ⇒ CssProxy
Returns a new instance of CssProxy.
4 5 6 7 |
# File 'lib/markaby/cssproxy.rb', line 4 def initialize(opts = {}, &blk) @opts = opts @blk = blk end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id_or_class, *args, &blk) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/markaby/cssproxy.rb', line 9 def method_missing(id_or_class, *args, &blk) idc = id_or_class.to_s case idc when /!$/ @opts[:id] = $` else @opts[:class] = "#{@opts[:class]} #{idc}".strip end if args.empty? and blk.nil? self else if args.last.respond_to? :to_hash @opts.merge!(args.pop.to_hash) end args.push @opts @blk.call(args, blk) end end |