Saturday, 12 January 2013

first post at netengine!

Not the best I've ever done, but I had to write something... A ruby implementation of the OAuth2 protocol for third party roles, enjoy!

http://goo.gl/UbHxI

Saturday, 5 January 2013

extend vs include

I always make confusion, although I'm getting better, this should help:


module MainMod
  module SubMod
    def self.included(cls)
      puts "#{self} included in #{cls}"
      cls.extend ClassMethods
    end

    module ClassMethods
      
      def ext
        puts 'extended'
      end
  
    end
  
    def inc
      puts 'included'
    end

  end
end

class A
  include MainMod::SubMod # => MainMod::SubMod included in A
end

A.new.inc
A.ext

module Mod1
  inc MainMod::SubMod
end

class B
  inc Mod1 # => MainMod::SubMod included in Mod1 !!!(Mod1)
end

B.new.inc
# B.ext # does not exists, `ext` was extended on Mod1