module PageRecord::Inspector

Public Class Methods

included(base) click to toggle source
# File lib/page_record/inspector.rb, line 5
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

inspect() click to toggle source
# File lib/page_record/inspector.rb, line 9
def inspect
  {
    attributes: attributes,
    actions: actions
  }
end

Private Instance Methods

attributes() click to toggle source

@private

# File lib/page_record/inspector.rb, line 19
def attributes
  attributes = {}
  self.class.attributes.each do | attribute|
    begin
      attributes[attribute] = read_attribute(attribute) do
        @record.all("[data-attribute-for='#{attribute}']").first
      end
    rescue NoMethodError
      attributes[attribute] = '--not found on page--'
    end
  end
 attributes['id'] = id
 attributes
end