Class: Attrocity::ModelAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/attrocity/attributes/model_attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, model_class) ⇒ ModelAttribute

Returns a new instance of ModelAttribute.



5
6
7
8
# File 'lib/attrocity/attributes/model_attribute.rb', line 5

def initialize(name, model_class)
  @name = name
  @model_class = model_class
end

Instance Attribute Details

#model_classObject (readonly)

Returns the value of attribute model_class.



3
4
5
# File 'lib/attrocity/attributes/model_attribute.rb', line 3

def model_class
  @model_class
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/attrocity/attributes/model_attribute.rb', line 3

def name
  @name
end

Instance Method Details

#model(data) ⇒ Object



10
11
12
# File 'lib/attrocity/attributes/model_attribute.rb', line 10

def model(data)
  model_class.new(AttributesHash.new(data)).model
end