lib/restpack_serializer/serializable/attributes.rb in restpack_serializer-0.2.5 vs lib/restpack_serializer/serializable/attributes.rb in restpack_serializer-0.2.6

- old
+ new

@@ -1,8 +1,14 @@ module RestPack::Serializer::Attributes extend ActiveSupport::Concern + module InstanceMethods + def default_href + "#{RestPack::Serializer.href_prefix}/#{@model.class.table_name}/#{@model.id}.json" + end + end + module ClassMethods def serializable_attributes @serializable_attributes end @@ -21,10 +27,11 @@ end def define_attribute_method(name) unless method_defined?(name) define_method name do - value = @model.send(name) + value = self.default_href if name == :href + value ||= @model.send(name) value = value.to_s if name == :id value end end end