Class: PollEverywhere::Serializable::Property

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/polleverywhere/serializable.rb

Overview

Property is somewhat of a metaclass that stores validations, name, etc. for the fields that belond to a serializable model. Since a Property lives at the class level, we have a Value class that

Defined Under Namespace

Classes: Set, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

included

Constructor Details

#initialize(name, configuration = {}) ⇒ Property

Returns a new instance of Property.



36
37
38
39
40
41
42
# File 'lib/polleverywhere/serializable.rb', line 36

def initialize(name, configuration={})
  self.name = name.to_sym
  # Set attributes on the class from a given hash
  configuration.each do |attr, args|
    self.send("#{attr}=", *args) if self.respond_to? "#{attr}="
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



32
33
34
# File 'lib/polleverywhere/serializable.rb', line 32

def name
  @name
end

#validationsObject

Returns the value of attribute validations.



32
33
34
# File 'lib/polleverywhere/serializable.rb', line 32

def validations
  @validations
end

Instance Method Details

#valueObject



44
45
46
# File 'lib/polleverywhere/serializable.rb', line 44

def value
  Value.new(self)
end