Class: BBCDataService::FeedFixture

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Serialization
Defined in:
lib/bbc_data_service/feed_fixture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ FeedFixture

Returns a new instance of FeedFixture.



9
10
11
12
13
14
15
16
17
# File 'lib/bbc_data_service/feed_fixture.rb', line 9

def initialize(attributes = {})
  @attributes = attributes
  @attributes.each do |name, value|
    FeedFixture.instance_eval <<-EOS
      attr_accessor :#{name}
    EOS
    send("#{name}=", value.to_s)
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



7
8
9
# File 'lib/bbc_data_service/feed_fixture.rb', line 7

def attributes
  @attributes
end

#rdf_objectObject

Returns the value of attribute rdf_object.



7
8
9
# File 'lib/bbc_data_service/feed_fixture.rb', line 7

def rdf_object
  @rdf_object
end

Instance Method Details

#add_relationship(name, values) ⇒ Object



19
20
21
22
23
24
# File 'lib/bbc_data_service/feed_fixture.rb', line 19

def add_relationship(name, values)
  FeedFixture.class_eval <<-EOS
    attr_accessor :#{name}
  EOS
  send("#{name}=", values)
end

#to_headerObject



26
27
28
# File 'lib/bbc_data_service/feed_fixture.rb', line 26

def to_header
  @attributes.map{|key, value| "#{key.upcase}: #{value}" }.join("\r\n")
end