MicroGems:
Eliminating barriers

Follow along at home

(I lied)

Takeaways from this talk

Hard road

Easy road

MicroGems

MicroGems Blog Post

#acts_as_boolean example

        class Comment < ActiveRecord::Base
          extend ActsAsBoolean

          acts_as_boolean :is_published
        end

        comment = Comment.new
        comment.is_published? # => false
        comment.is_published = 'yes'
        comment.is_published? #=> true
      

gist.github.com/1302883

        module ActsAsBoolean
          def acts_as_boolean(*attributes)
            [*attributes].each do |attribute|

              # Define the = setter method
              attr_writer attribute

              # Define the ? accessor method
              define_method("#{attribute}?") { !!instance_variable_get("@#{attribute}") }

            end
          end
        end

        ActiveRecord::Base.send :extend, ActsAsBoolean
      

#bang example

        class Comment < ActiveRecord::Base
          extend Bang

          bang :permalink_title => :permalink

          before_save :permalink_title!

          def permalink_title
            title.parameterize
          end
        end
      

gist.github.com/1232884

        module Bang

          def bang(attributes)

            [*attributes].each do |attribute|
              key, value = attribute
              define_method("#{key}!") { update_attribute(value || key, send(key)) }
            end

          end

        end
      

What about my Gemfile?

        ...
        gem 'acts_as_boolean', :git => 'git://gist.github.com/1302883.git'
        ...
      

(there are drawbacks)

micro-cutter

Outputs a gem skeleton because:

Usina Mini-Cutter

        # Call the executable, passing a camel cased class name:

          mini-cutter ActsAsBoolean

        # This creates boilerplate files (overwriting any already there):

          README.md
          acts_as_boolean.gemspec
          acts_as_boolean.rb
          acts_as_boolean_spec.rb
      

Takeaways from this talk

Help me improve

Credits