Class: FlightFacade::BaseHashieDashModel
- Inherits:
-
Object
- Object
- FlightFacade::BaseHashieDashModel
- Defined in:
- lib/flight_facade/models.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*a) ⇒ BaseHashieDashModel
constructor
A new instance of BaseHashieDashModel.
- #jsonapi_serializer_class_name ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(*a) ⇒ BaseHashieDashModel
Returns a new instance of BaseHashieDashModel.
57 58 59 |
# File 'lib/flight_facade/models.rb', line 57 def initialize(*a) @data = self.class::DataHash.new(*a) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
55 56 57 |
# File 'lib/flight_facade/models.rb', line 55 def data @data end |
Class Method Details
._jsonapi_serializer_class_name ⇒ Object
47 48 49 |
# File 'lib/flight_facade/models.rb', line 47 def self._jsonapi_serializer_class_name @_jsonapi_serializer_class_name ||= name.split('::').last + 'Serializer' end |
._type ⇒ Object
51 52 53 |
# File 'lib/flight_facade/models.rb', line 51 def self._type @_type ||= name.split('::').last.demodulize.tableize.dasherize end |
.inherited(klass) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/flight_facade/models.rb', line 33 def self.inherited(klass) data_class = Class.new(Hashie::Dash) do include Hashie::Extensions::IgnoreUndeclared include ActiveModel::Validations def self.method_added(m) parent.delegate(m, to: :data) end end klass.const_set('DataHash', data_class) klass.delegate(*(ActiveModel::Validations.instance_methods - Object.methods), to: :data) end |
Instance Method Details
#jsonapi_serializer_class_name ⇒ Object
61 62 63 |
# File 'lib/flight_facade/models.rb', line 61 def jsonapi_serializer_class_name self.class._jsonapi_serializer_class_name end |
#type ⇒ Object
65 66 67 |
# File 'lib/flight_facade/models.rb', line 65 def type self.class._type end |