Class: ActiveNutrition::Objects::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_nutrition/objects/base.rb

Direct Known Subclasses

Food, FoodGroup, NutritionFact, Weight

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_model) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/active_nutrition/objects/base.rb', line 8

def initialize(base_model)
  @base_model = base_model
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/active_nutrition/objects/base.rb', line 6

def attributes
  @attributes
end

#base_modelObject (readonly)

Returns the value of attribute base_model.



6
7
8
# File 'lib/active_nutrition/objects/base.rb', line 6

def base_model
  @base_model
end

Class Method Details

.wrap(obj) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/active_nutrition/objects/base.rb', line 16

def self.wrap(obj)
  if obj.is_a?(Array)
    obj.map { |o| new(o) }
  else
    new(obj)
  end
end