Class: Rails::AddOns::Service::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Model, Attributes, Autosave, Callbacks, Errors, Internationalization, Resultable, Messages
Defined in:
app/services/rails/add_ons/service/base.rb

Defined Under Namespace

Modules: Attributes, Autosave, Callbacks, Errors, Internationalization, Resultable

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Internationalization

#t

Methods included from Autosave

#autosave!, #autosave?

Methods included from Callbacks

#after_initialize, #after_perform, #after_validation, #before_perform, #before_validation, #perform

Methods included from Attributes

#set_attributes

Methods included from ActiveModel::Model

included, #persisted?

Constructor Details

#initialize(attributes = {}, options = {}, &block) ⇒ Base


27
28
29
30
31
32
33
34
35
36
# File 'app/services/rails/add_ons/service/base.rb', line 27

def initialize(attributes = {}, options = {}, &block)
  @options    = options
  @block      = block
  @attributes = {}
  set_attributes(attributes)
  initialize_result
  initialize_errors
  initialize_messages
  after_initialize
end

Class Method Details

.add_attribute_names(*args) ⇒ Object


13
14
15
16
17
# File 'app/services/rails/add_ons/service/base.rb', line 13

def self.add_attribute_names(*args)
  args.each do |attr_name|
    attribute_names << attr_name
  end
end

.attr_accessor(*args) ⇒ Object


8
9
10
11
# File 'app/services/rails/add_ons/service/base.rb', line 8

def self.attr_accessor(*args)
  super
  add_attribute_names(*args)
end

.attribute_namesObject


19
20
21
# File 'app/services/rails/add_ons/service/base.rb', line 19

def self.attribute_names
  (@attr_names ||= [])
end

.call(*args) ⇒ Object


23
24
25
# File 'app/services/rails/add_ons/service/base.rb', line 23

def self.call(*args)
  new(*args).perform
end