Sha256: 02c9aa005795d56bec17a47075484b74ef80f8440013e395311b6c522237e7f9

Contents?: true

Size: 957 Bytes

Versions: 3

Compression:

Stored size: 957 Bytes

Contents

require "hashme/version"

# External dependencies

require "active_model"
require "active_model/naming"
require "active_model/serialization"

require "active_support/core_ext"
require "active_support/json"

# Local dependencies

require "hashme/attributes"
require "hashme/castable"
require "hashme/casted_array"
require "hashme/properties"
require "hashme/property"
require "hashme/property_casting"
require "hashme/validations/casted_attribute_validator"
require "hashme/validations"

module Hashme
  extend ActiveSupport::Concern

  include Validations

  included do
    include Castable
    include Attributes
    include Properties
  end

  def initialize(attrs = {})
    # Use the `Properties` module's methods
    set_defaults
    set_attributes(attrs)
  end

  module ClassMethods
    # Little help. Equivalent to new.tap
    def build(*attrs)
      instance = self.new(*attrs)
      yield instance if block_given?
      instance
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hashme-0.2.3 lib/hashme.rb
hashme-0.2.2 lib/hashme.rb
hashme-0.2.1 lib/hashme.rb