Sha256: 40f969a5e55d0bb62a22cc19e80c97d34d107590bfc3d05b054b4c4fbc6541f5

Contents?: true

Size: 724 Bytes

Versions: 28

Compression:

Stored size: 724 Bytes

Contents

module Acfs::Model

  # Initialization drop-in for pre-4.0 ActiveModel.
  #
  module Initialization

    # @api public
    #
    # Initializes a new model with the given `params`.
    #
    # @example
    #   class User
    #     include Acfs::Model
    #     attribute :name
    #     attribute :email, default: -> { "#{name}@dom.tld" }
    #     attribute :age, :integer, default: 18
    #   end
    #
    #   user = User.new(name: 'bob')
    #   user.name  # => "bob"
    #   user.email # => "bob@dom.tld"
    #   user.age   # => 18
    #
    # @param [ Hash{ Symbol => Object } ] params Attributes to set on resource.
    #
    def initialize(params = {})
      self.write_attributes params if params
    end

  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
acfs-0.34.0 lib/acfs/model/initialization.rb
acfs-0.33.1.1.b285 lib/acfs/model/initialization.rb
acfs-0.33.1.1.b281 lib/acfs/model/initialization.rb
acfs-0.33.1 lib/acfs/model/initialization.rb
acfs-0.33.0.1.b278 lib/acfs/model/initialization.rb
acfs-0.33.0 lib/acfs/model/initialization.rb
acfs-0.32.1.1.b277 lib/acfs/model/initialization.rb
acfs-0.32.1.1.b276 lib/acfs/model/initialization.rb