Class: AngularSprinkles::ConstructorCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/angular_sprinkles/constructor_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ConstructorCollection

Returns a new instance of ConstructorCollection.



3
4
5
6
7
# File 'lib/angular_sprinkles/constructor_collection.rb', line 3

def initialize(args)
  @json_wrapper = args.fetch(:json_wrapper)
  @object_wrapper = args.fetch(:object_wrapper)
  @collection = []
end

Instance Method Details

#push(object, key) ⇒ Object



9
10
11
12
13
# File 'lib/angular_sprinkles/constructor_collection.rb', line 9

def push(object, key)
  bundle = @object_wrapper.new(object, key, @json_wrapper)

  @collection.push(bundle)
end

#to_jsonObject Also known as: to_s



15
16
17
# File 'lib/angular_sprinkles/constructor_collection.rb', line 15

def to_json
  @collection.map!(&:to_json).join("\n")
end