Sha256: 5aad4b5e0791dd1006cc1809b0f0345fe3e0a7859d615529fb525a0fa9c790a4

Contents?: true

Size: 767 Bytes

Versions: 24

Compression:

Stored size: 767 Bytes

Contents

class Admin::EmployeeFactory
  delegate :save!,
    to: :_employee
  def initialize(input_params)
    @params = input_params.permit *Apiv1::Employee::Fields
    @raw_pictures = _arrayify(input_params[:pictures])
  end
  def satisfy_specifications?
    _pictures.all?(&:valid?) && _employee.valid?
  end
  def employee_hash
    { employee: _employee.to_ember_hash }
  end
  def error_hash
    _employee.errors.to_h
  end
  private
  def _employee
    @employee ||= Apiv1::Employee.new @params
  end
  def _pictures
    @pictures ||= _employee.pictures.new _picture_params
  end
  def _picture_params
    @raw_pictures.map { |pic| { pic: pic } }
  end
  def _arrayify(array_like)
    return array_like if array_like.is_a? Array
    array_like.to_a.map(&:last)
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
cloudrider-0.3.23 generica/app/models/admin/employee_factory.rb
cloudrider-0.3.22 generica/app/models/admin/employee_factory.rb
cloudrider-0.3.21 generica/app/models/admin/employee_factory.rb
cloudrider-0.3.20 generica/app/models/admin/employee_factory.rb
cloudrider-0.3.0 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.18 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.15 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.14 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.12 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.11 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.10 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.9 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.8 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.7 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.6 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.5 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.4 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.3 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.2 generica/app/models/admin/employee_factory.rb
cloudrider-0.2.1 generica/app/models/admin/employee_factory.rb