Class: ClassKit::AttributeHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/class_kit/attribute_helper.rb

Instance Method Summary collapse

Instance Method Details

#get_attribute(klass:, name:) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/class_kit/attribute_helper.rb', line 7

def get_attribute(klass:, name:)
  attribute = get_attributes(klass).detect { |i| i[:name] == name }
  if attribute == nil
    raise ClassKit::Exceptions::AttributeNotFoundError.new("Attribute: #{name}, could not be found.")
  end
  return attribute
end

#get_attribute_type(klass:, name:) ⇒ Object



15
16
17
# File 'lib/class_kit/attribute_helper.rb', line 15

def get_attribute_type(klass:,name:)
  return get_attribute(klass: klass,name: name)[:type]
end

#get_attributes(klass) ⇒ Object



3
4
5
# File 'lib/class_kit/attribute_helper.rb', line 3

def get_attributes(klass)
  return klass.class_variable_get(:@@class_kit_attributes).freeze
end