Sha256: 5dbc3665fa850761d7f07674438cfcf0559bd1b88089aa2c142afbaa57b0dab9

Contents?: true

Size: 670 Bytes

Versions: 4

Compression:

Stored size: 670 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 populate
      @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

4 entries across 4 versions & 1 rubygems

Version Path
grom-0.3.2 lib/grom/node.rb
grom-0.3.1 lib/grom/node.rb
grom-0.3.0 lib/grom/node.rb
grom-0.2.0 lib/grom/node.rb