Class: TypedAttributes::Parser::BaseType

Inherits:
Object
  • Object
show all
Defined in:
lib/typed_attributes/parser/base_type.rb

Direct Known Subclasses

ArrayType, BooleanType, DateTimeType, StringType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, attr, options = {}) ⇒ BaseType

Returns a new instance of BaseType.



7
8
9
10
11
# File 'lib/typed_attributes/parser/base_type.rb', line 7

def initialize(model, attr, options = {})
  @model = model
  @attribute = attr
  @options = options || {}
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



5
6
7
# File 'lib/typed_attributes/parser/base_type.rb', line 5

def attribute
  @attribute
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/typed_attributes/parser/base_type.rb', line 5

def model
  @model
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/typed_attributes/parser/base_type.rb', line 5

def options
  @options
end

Instance Method Details

#parse(value) ⇒ Object

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/typed_attributes/parser/base_type.rb', line 13

def parse(value)
  raise NotImplementedError.new
end

#readersObject



21
22
23
# File 'lib/typed_attributes/parser/base_type.rb', line 21

def readers
  [attribute]
end

#storage_varObject



17
18
19
# File 'lib/typed_attributes/parser/base_type.rb', line 17

def storage_var
  :"@#{attribute}"
end

#writersObject



25
26
27
# File 'lib/typed_attributes/parser/base_type.rb', line 25

def writers
  [:"#{attribute}="]
end