Class: FlexiModel::Fields::FlexiField

Inherits:
Object
  • Object
show all
Defined in:
lib/flexi_model/fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, default = nil) ⇒ FlexiField

Returns a new instance of FlexiField.



274
275
276
277
278
279
# File 'lib/flexi_model/fields.rb', line 274

def initialize(name, type, default = nil)
  @name    = name
  @type    = type
  @default = default
  @options = { }
end

Instance Attribute Details

#accessibleObject

Returns the value of attribute accessible.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def accessible
  @accessible
end

#defaultObject

Returns the value of attribute default.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def default
  @default
end

#nameObject

Returns the value of attribute name.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def name
  @name
end

#optionsObject

Returns the value of attribute options.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def options
  @options
end

#pluralObject

Returns the value of attribute plural.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def plural
  @plural
end

#singularObject

Returns the value of attribute singular.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def singular
  @singular
end

#typeObject

Returns the value of attribute type.



272
273
274
# File 'lib/flexi_model/fields.rb', line 272

def type
  @type
end

Instance Method Details

#value(context) ⇒ Object



281
282
283
284
285
286
287
# File 'lib/flexi_model/fields.rb', line 281

def value(context)
  if default.is_a?(Proc)
    default.call(context)
  else
    default
  end
end