Class: Foxynews::Pressroom

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Pressroom

Returns a new instance of Pressroom.



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

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

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