Class: Frigate::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/frigate/function.rb

Overview

Examples:

class Song::AddArtistService < Frigate::Service
  property :song
  property :artist

  def function
    song.artists << artist
  end
end

Song::AddArtistService[song: song, artist: artist]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Function

Returns a new instance of Function.

Parameters:

  • attrs (Hash)


28
29
30
# File 'lib/frigate/function.rb', line 28

def initialize(attrs)
  attrs.each { |key, val| instance_variable_set("@#{key}", val) }
end

Class Method Details

.[]Object

Parameters:

  • attrs (Hash)


24
25
26
# File 'lib/frigate/function.rb', line 24

def run(attrs)
  new(attrs).run
end

.property(name) ⇒ Object

Parameters:

  • name (Symbol)


15
16
17
# File 'lib/frigate/function.rb', line 15

def property(name)
  class_eval { attr_reader name }
end

.run(attrs) ⇒ Object

Parameters:

  • attrs (Hash)


20
21
22
# File 'lib/frigate/function.rb', line 20

def run(attrs)
  new(attrs).run
end

Instance Method Details

#functionObject

here you should write your function code =)

Raises:

  • (NotImplemented)


38
39
40
# File 'lib/frigate/function.rb', line 38

def function
  raise NotImplemented
end

#runObject

to perform/run the service actionstasks



33
34
35
# File 'lib/frigate/function.rb', line 33

def run
  function
end