class Fried::Schema::GetAttribute

Get attribute value from object

Public Class Methods

build() click to toggle source
# File lib/fried/schema/get_attribute.rb, line 6
def self.build
  new
end
call(obj, attribute) click to toggle source
# File lib/fried/schema/get_attribute.rb, line 10
def self.call(obj, attribute)
  instance = build
  instance.(obj, attribute)
end

Public Instance Methods

call(obj, attribute) click to toggle source

@param obj [Object] anything @param attribute [Attribute::Definition] @return [Object] value from the object attribute

# File lib/fried/schema/get_attribute.rb, line 18
def call(obj, attribute)
  reader = attribute.reader
  obj.public_send(reader)
end