Sha256: eb0826d142f651f8f626e824e61ad417250e73273d60f9ca657057712835ea71

Contents?: true

Size: 556 Bytes

Versions: 1

Compression:

Stored size: 556 Bytes

Contents

require 'poro_properties/version'

module PoroProperties
  def self.included(base)
    base.extend ClassMethods
  end

  def to_h
    self.class.properties_names
      .inject({}) { |memo, key| memo.merge(key => public_send(key)) }
  end

  module ClassMethods
    attr_accessor :properties_names

    def properties(*names)
      attr_accessor(*names)
      @properties_names ||= []
      @properties_names += names
    end

    def property(name)
      attr_accessor(name)
      @properties_names ||= []
      @properties_names << name
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
poro_properties-0.1.0 lib/poro_properties.rb