Class: Oat::Adapters::Siren::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/oat/adapters/siren.rb

Defined Under Namespace

Classes: Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Action

Returns a new instance of Action.


69
70
71
# File 'lib/oat/adapters/siren.rb', line 69

def initialize(name)
  @data = { :name => name, :class => [], :fields => [] }
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data


67
68
69
# File 'lib/oat/adapters/siren.rb', line 67

def data
  @data
end

Instance Method Details

#class(value) ⇒ Object


73
74
75
# File 'lib/oat/adapters/siren.rb', line 73

def class(value)
  data[:class] << value
end

#field(name, &block) ⇒ Object


77
78
79
80
81
82
# File 'lib/oat/adapters/siren.rb', line 77

def field(name, &block)
  field = Field.new(name)
  block.call(field)

  data[:fields] << field.data
end