module Acfs::Resource::Initialization
Initialization
drop-in for pre-4.0 ActiveModel.
Public Class Methods
new(attributes = {})
click to toggle source
@api public
Initializes a new model with the given ‘params`.
@example
class User < Acfs::Resource 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 attributes [Hash{Symbol => Object}] Attributes
to set on resource.
# File lib/acfs/resource/initialization.rb, line 27 def initialize(attributes = {}) write_attributes(attributes) if attributes end