Sha256: e4685201bf431ed8f69da987ffa3e28356fc218ba91f2f4c2045fe07c8ddac56

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

require "simple-hd-graph/node"

module SimpleHdGraph
  class ResourceNode < Node
    #
    # @param context [Object]
    # @param struct [Hash]
    #
    def load_with_context(context, struct)
      @context = context
      load(struct)
    end

    #
    # @return [String]
    #
    def alias
      @content.keys.first.to_s.freeze
    end

    #
    # @return [String]
    #
    def id
      id = camelize(context)
      id[0] = id[0].downcase
      [id, camelize(self.alias)].join("").freeze
    end

    #
    # @return [String]
    #
    def context
      @context[:id].freeze
    end

    #
    # @return [Hash]
    #
    def content
      @content.values.first.select { |key, value| # rubocop:disable Style/HashExcept
        key != "has"
      }
    end

    #
    # @return [Array]
    #
    def has
      @content.values.first["has"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple-hd-graph-0.3.5 lib/simple-hd-graph/resource.rb