Sha256: 97d07fa05c6c7d509ad9061560cb9cf94fbdca917574caed479adbd958848cae

Contents?: true

Size: 454 Bytes

Versions: 3

Compression:

Stored size: 454 Bytes

Contents

module TelegramOnSteroids
  module Configurable
    def configure(&block)
      define_method(:configure!) do
        instance_eval { block.call(self) }
      end

      define_method(:after_initialize) do
        configure!
      end
    end

    def callable(name)
      attr_writer(name)

      define_method(name) do
        var = instance_variable_get("@#{name.to_s}")
        var.is_a?(Proc) ? instance_eval(&var) : var
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
telegram_on_steroids-0.1.2 lib/telegram_on_steroids/configurable.rb
telegram_on_steroids-0.1.1 lib/telegram_on_steroids/configurable.rb
telegram_on_steroids-0.1.0 lib/telegram_on_steroids/configurable.rb