Class: ActiveFormObjects::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Dsl::Attributes, Dsl::Debug, Dsl::Delegates, Dsl::ErrorHandling, Dsl::Hooks, Dsl::Polymorphs, Dsl::Relations, Dsl::Resource, Dsl::Savings, Dsl::Scopes
Defined in:
lib/active_form_objects.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dsl::Savings

#save, #save!, #validate!

Methods included from Dsl::ErrorHandling

#map_errors_to

Methods included from Dsl::Attributes

#attributes, #attrs_only

Constructor Details

#initialize(params, resource = nil) ⇒ Base

Returns a new instance of Base.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_form_objects.rb', line 42

def initialize(params, resource = nil)
  raise ActiveFormObjects::HandlerError, "[#{self.class.name}] params were not correclty declared" unless params.is_a?(Hash)

  @params = params.with_indifferent_access
  @resource = resource

  Handlers::Initializer.handle(self)
  Handlers::Resource.handle(self)
  Handlers::Attributes.handle(self)
  Handlers::Debug.handle(self)
  super(@params)
end

Class Method Details

.inherited(subclass) ⇒ Object



38
39
40
# File 'lib/active_form_objects.rb', line 38

def self.inherited(subclass)
  Handlers::Inheritance.handle(subclass, self)
end