Sha256: 780332fea912cf8fea9eb7cfdb1b1bfbbd8c1dc2c320dd6860288526e517dd2a

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

module Grom
  class Node
    attr_reader :statements

    def initialize(statements)
      @statements = statements

      populate
    end

    def method_missing(method, *params, &block)
      instance_variable_get("@#{method}".to_sym) || super
    end

    def respond_to_missing?(method, include_private = false)
      instance_variable_get("@#{method}".to_sym) || super
    end

    private

    def set_graph_id
      graph_id = Grom::Helper.get_id(@statements.first.subject)
      instance_variable_set('@graph_id'.to_sym, graph_id)
    end

    def populate
      set_graph_id
      @statements.each do |statement|
        attribute_name = Grom::Helper.get_id(statement.predicate)
        attribute_value = statement.object.to_s
        instance_variable_set("@#{attribute_name}".to_sym, attribute_value)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grom-0.3.5 lib/grom/node.rb