Sha256: 9d59a80687b8abdfcea0d490eadd86bd7a50643b9408a1bc546f3c5bc2913617

Contents?: true

Size: 864 Bytes

Versions: 7

Compression:

Stored size: 864 Bytes

Contents

class Company < AbstractAdapter
  has_many :roles, as: :ownable
  has_many :admins, through: :roles, source: :user
  accepts_nested_attributes_for :roles, allow_destroy: true
  
  has_many :beacons, class_name: 'LocationBeacon', dependent: :destroy
  has_many :locatables
  has_many :locations, through: :locatables, source: :locatable, source_type: 'Company'

  has_many :projects, foreign_key: :owner_id, dependent: :destroy, inverse_of: :owner

  validates_length_of :name, maximum: 256
  validates_length_of :short_name, maximum: 10

  def self.grape_validations
    {
      gizmos: { json: true },
      widgets: { json_array: true },
      sprockets: { json_hash: true }
    }
  end

  def gizmos=(json)
    JSON.parse(json)
  end

  def widgets=(json_array)
    JSON.parse(json_array)
  end

  def sprockets=(json_hash)
    JSON.parse(json_hash)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
introspective_grape-0.3.2 spec/dummy/app/models/company.rb
introspective_grape-0.3.1 spec/dummy/app/models/company.rb
introspective_grape-0.3.0 spec/dummy/app/models/company.rb
introspective_grape-0.2.9 spec/dummy/app/models/company.rb
introspective_grape-0.2.8 spec/dummy/app/models/company.rb
introspective_grape-0.2.7 spec/dummy/app/models/company.rb
introspective_grape-0.2.6 spec/dummy/app/models/company.rb