Module: Icss::ReceiverModel::ActsAsLoadable::ClassMethods

Included in:
Icss::ReceiverModel::ActsAsCatalog::ClassMethods
Defined in:
lib/icss/receiver_model/acts_as_loadable.rb

Instance Method Summary collapse

Instance Method Details

#receive_from_file(filename) ⇒ Object

The file is loaded with

  • YAML if the filename ends in .yaml or .yml

  • JSON otherwise



33
34
35
36
# File 'lib/icss/receiver_model/acts_as_loadable.rb', line 33

def receive_from_file filename
  stream = File.open(filename)
  (filename =~ /.ya?ml$/) ? receive_yaml(stream) : receive_json(stream)
end

#receive_json(stream) ⇒ Object

module ::Icss::ReceiverModel::ClassMethods

include Icss::ReceiverModel::ActsAsLoadable::ClassMethods

end



20
21
22
# File 'lib/icss/receiver_model/acts_as_loadable.rb', line 20

def receive_json stream
  receive(JSON.load(stream))
end

#receive_yaml(stream) ⇒ Object



24
25
26
# File 'lib/icss/receiver_model/acts_as_loadable.rb', line 24

def receive_yaml stream
  receive(YAML.load(stream))
end