Modules

Drupal module development - permissions

As promised, after my Python bragging we're going to resume and wrap-up everything on our dfacebox module. If you still remember, our test page is accessible to anonymous users (users that are not registered). You don't normally exposed module settings or test pages like this so instead, we're going to apply some restriction so only those that have permission to access it will be able to view except for the root account which pretty much can do everything.

Ruby Mixins

I've been playing around with Ruby's mixins today and It's really fun. Here's a snippet:

  1. module Greeter
  2.  
  3. def who_am_i?
  4. "#{self.class.name}"
  5. end
  6.  
  7. def greet
  8. puts "Hello #{@name}"
  9. end
  10.  
  11. end
  12.  
  13. class Student
  14.  
  15. def initialize(n)
  16. @name = n
  17. end
  18.  
  19. include Greeter
  20. end
  21.  
  22. class Teacher
  23.  
  24. def initialize(n)
  25. @name = n
  26. end
  27.  
  28. include Greeter
  29. end

Now fire up irb and do this:

Syndicate content