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