Class: Foxynews::Presskit

Inherits:
Object
  • Object
show all
Defined in:
app/services/foxynews/presskit.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Presskit

Returns a new instance of Presskit.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/services/foxynews/presskit.rb', line 3

def initialize(args)
  if args.is_a? Hash
    args.each do |name, value|
      value.map! {|m| OpenStruct.new(m) } if name == 'media' && value.present?

      instance_variable_set("@#{name}", value)
      self.class.send(:attr_accessor, name)
    end
  else
    false
  end
end

Instance Method Details

#media_items(limit = 1) ⇒ Object



16
17
18
# File 'app/services/foxynews/presskit.rb', line 16

def media_items(limit = 1)
  media.take(limit)
end