Sha256: 05609a8d8e00f635b8ccced9e1daa0c7fa94fb753eafda8aca41aded6ea0fbb6

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

Stored size: 603 Bytes

Contents

module Shogun
  module Normalizer
    def to_hash
      attributes.inject({}) do |hash, attribute|
        if public_send(attribute)
          hash.merge(attribute => public_send(attribute))
        else
          hash
        end
      end
    end

    def as_meta
      metadata.inject({}) do |hash, meta|
        if public_send(meta)
          hash.merge(meta => public_send(meta))
        else
          hash
        end
      end
    end

    private def attributes
      self.class.const_get("ATTRIBUTES")
    end

    private def metadata
      self.class.const_get("METADATA")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shogun-2.1.1 lib/shogun/normalizer.rb
shogun-2.1.0 lib/shogun/normalizer.rb
shogun-2.0.0 lib/shogun/normalizer.rb
shogun-1.0.0 lib/shogun/normalizer.rb