Sha256: 0acd57c76967da97e756db89e075f7a754228b5075219cfddff118c140bcfd5d

Contents?: true

Size: 684 Bytes

Versions: 12

Compression:

Stored size: 684 Bytes

Contents

class ProjectPresenter
  include UrlHelper

  def initialize(projects)
    @projects = OneOrMany.new(projects)
  end

  def as_json(*args)
    projects = @projects
    projects = Houston.benchmark "[#{self.class.name.underscore}] Load objects" do
      projects.load
    end if projects.is_a?(ActiveRecord::Relation)
    Houston.benchmark "[#{self.class.name.underscore}] Prepare JSON" do
      projects.map(&method(:project_to_json))
    end
  end

  def project_to_json(project)
    { id: project.id,
      name: project.name,
      slug: project.slug,
      color: {
        name: project.color,
        hex: project.color_value.hex },
      props: project.props.to_h }
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
houston-core-0.8.4 app/presenters/project_presenter.rb
houston-core-0.8.3 app/presenters/project_presenter.rb
houston-core-0.8.2 app/presenters/project_presenter.rb
houston-core-0.8.1 app/presenters/project_presenter.rb
houston-core-0.8.0 app/presenters/project_presenter.rb
houston-core-0.8.0.pre2 app/presenters/project_presenter.rb
houston-core-0.8.0.pre app/presenters/project_presenter.rb
houston-core-0.7.0 app/presenters/project_presenter.rb
houston-core-0.7.0.beta4 app/presenters/project_presenter.rb
houston-core-0.7.0.beta3 app/presenters/project_presenter.rb
houston-core-0.7.0.beta2 app/presenters/project_presenter.rb
houston-core-0.7.0.beta app/presenters/project_presenter.rb