Sha256: 74ef0e8066e79a41e09fbad1e8a928b9a1dd60601f2d104f30be74f932de0aa4

Contents?: true

Size: 707 Bytes

Versions: 23

Compression:

Stored size: 707 Bytes

Contents

class Shoes
  class Widget
    def self.inherited klass, &blk
      m = klass.to_s[/(^|::)(\w+)$/, 2].
              gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
              gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
      Shoes::App.class_eval do
        define_method m do |*args, &blk|
          klass.class_variable_set :@@__app__, self
          parent = app.cslot
          klass.new(*args, &blk).tap do |s|
            s.define_singleton_method(:parent){parent}
          end
        end
      end
      klass.class_eval do
        define_method :method_missing do |*args, &blk|
          klass.class_variable_get(:@@__app__).send *args, &blk
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
green_shoes-1.1.374 lib/shoes/widget.rb
green_shoes-1.1.373 lib/shoes/widget.rb
green_shoes-1.1.367 lib/shoes/widget.rb
green_shoes-1.1.366 lib/shoes/widget.rb
green_shoes-1.1.365 lib/shoes/widget.rb
green_shoes-1.1.364 lib/shoes/widget.rb
green_shoes-1.1.363 lib/shoes/widget.rb
green_shoes-1.1.362 lib/shoes/widget.rb
green_shoes-1.1.358 lib/shoes/widget.rb
green_shoes-1.1.357 lib/shoes/widget.rb
green_shoes-1.1.354 lib/shoes/widget.rb
green_shoes-1.1.348 lib/shoes/widget.rb
green_shoes-1.0.337 lib/shoes/widget.rb
green_shoes-1.0.331 lib/shoes/widget.rb
green_shoes-1.0.322 lib/shoes/widget.rb
green_shoes-1.0.320 lib/shoes/widget.rb
green_shoes-1.0.309 lib/shoes/widget.rb
green_shoes-1.0.303 lib/shoes/widget.rb
green_shoes-1.0.282 lib/shoes/widget.rb
green_shoes-1.0.273 lib/shoes/widget.rb