Sha256: 74e227d23b09c70b14811ae26a02c412963fcedbd54e86332059a40201d57fc6

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

class Dummy::UserAPI < IntrospectiveGrape::API

  skip_presence_validations :password

  include_actions User, :all
  exclude_actions Role, :show,:update
  exclude_actions UserProjectJob, :show,:update

  filter_on :all

  restful User, [:id, :email, :password, :first_name, :last_name, :skip_confirmation_email,
    :created_at, :updated_at,
    user_project_jobs_attributes: [:id, :job_id, :project_id, :_destroy],
    roles_attributes: [:id, :ownable_type, :ownable_id, :_destroy],
    avatar_attributes: [:id, :file, :_destroy]
  ]

  class RoleEntity < Grape::Entity
    expose :id, :ownable_type, :ownable_id
  end

  class ImageEntity < Grape::Entity
    expose :id, :file_processing #, 'file.url'
  end

  class UserProjectJobEntity < Grape::Entity
    expose :id, :name, :title, :job_id, :project_id
  end

  class UserEntity < Grape::Entity
    expose :id, :email, :first_name, :last_name, :avatar_url, :created_at
    expose :roles, as: :roles_attributes, using: RoleEntity
    expose :user_project_jobs, as: :user_project_jobs_attributes, using: UserProjectJobEntity
  end 

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
introspective_grape-0.2.7 spec/dummy/app/api/dummy/user_api.rb
introspective_grape-0.2.6 spec/dummy/app/api/dummy/user_api.rb
introspective_grape-0.2.5 spec/dummy/app/api/dummy/user_api.rb
introspective_grape-0.2.4 spec/dummy/app/api/dummy/user_api.rb
introspective_grape-0.2.3 spec/dummy/app/api/dummy/user_api.rb
introspective_grape-0.2.2 spec/dummy/app/api/dummy/user_api.rb