Sha256: b03f720152fde46c9682dc1e82135310994295d1cb0a5c1c478e01b75002c028

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

Stored size: 777 Bytes

Contents

module Mayu
  Map = Struct.new(:key, :name, :url, :fg_color, :bg_color, :highlight_color, keyword_init: true) do
    include Mayu::Relation

    def self.load(obj)
      new(**obj)
    end

    relates :aps

    def associations
      @associations ||= aps.flat_map(&:associations)
    end
    def devices
      @devices ||= aps.flat_map(&:devices)
    end
    def users
      @users ||= aps.flat_map(&:users)
    end

    def associations_count
      associations.size
    end
    def devices_count
      devices.size
    end
    def users_count
      users.size
    end

    def as_json
      {
        key: key,
        name: name,
        url: url,
        fg_color: fg_color,
        bg_color: bg_color,
        highlight_color: highlight_color,
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mayu-0.1.0.beta1 lib/mayu/map.rb