Sha256: d0c6cfa7e68a091a14faaefeb4f0c13b03986639ec0236beb2cdbb2d0dc19a11

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

require 'poro_properties/version'
require 'poro_properties/defaults'

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.1 lib/poro_properties.rb