Sha256: 74a37b77ec533beb7c0ae8ea5348c95f77e2a77d0eb598c428ce183de431f83b

Contents?: true

Size: 416 Bytes

Versions: 1

Compression:

Stored size: 416 Bytes

Contents

module Mutator
  module Helpers
    def machine
      @machine ||= machine_class.new(self)
    end

    def self.included(base)
      "Machines::#{base.name}".constantize.states.each do |state|
        base.send(:define_singleton_method, state) do
          self.where(state: state)
        end
      end
    end

  protected

    def machine_class
      "Machines::#{self.class.name}".constantize
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mutator-0.0.1 lib/mutator/helpers.rb