Class: HexWrench::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/hexwrench/core/feature.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sym, resource) ⇒ Feature

Returns a new instance of Feature.



21
22
23
24
# File 'lib/hexwrench/core/feature.rb', line 21

def initialize(sym, resource)
  @resource = resource
  @sym = sym
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



19
20
21
# File 'lib/hexwrench/core/feature.rb', line 19

def resource
  @resource
end

#symObject

Returns the value of attribute sym.



19
20
21
# File 'lib/hexwrench/core/feature.rb', line 19

def sym
  @sym
end

Class Method Details

.for(sym, resource, type) ⇒ Object

Raises:

  • (ArgumentError.new)


13
14
15
16
17
# File 'lib/hexwrench/core/feature.rb', line 13

def self.for(sym, resource, type)
  raise ArgumentError.new, "not understood type: #{type}" unless mapping.has_key?(type)
  klass = mapping[type]
  klass.new(sym, resource)
end

.mappingObject



4
5
6
7
8
9
10
11
# File 'lib/hexwrench/core/feature.rb', line 4

def self.mapping
  {:numeric => NumericFeature,
    :date => DateFeature,
    :nominal => NominalFeature,
    :string => StringFeature,
    :related => RelationFeature
  }
end