Kouhei Sutou
null+****@clear*****
Tue Dec 27 15:08:10 JST 2016
Kouhei Sutou 2016-12-27 15:08:10 +0900 (Tue, 27 Dec 2016) New Revision: d909aeba54a98f64a7728740093ebb64bf9af211 https://github.com/ranguba/groonga-client-model/commit/d909aeba54a98f64a7728740093ebb64bf9af211 Message: Support Rails 4 Copied files: lib/groonga_client_model/attribute_assignment.rb (from lib/groonga-client-model.rb) Modified files: lib/groonga-client-model.rb lib/groonga_client_model/record.rb Modified: lib/groonga-client-model.rb (+1 -0) =================================================================== --- lib/groonga-client-model.rb 2016-12-27 14:43:00 +0900 (c2cad11) +++ lib/groonga-client-model.rb 2016-12-27 15:08:10 +0900 (334d664) @@ -20,6 +20,7 @@ require "groonga/client" require "groonga_client_model/version" +require "groonga_client_model/attribute_assignment" require "groonga_client_model/client" require "groonga_client_model/client_opener" require "groonga_client_model/error" Copied: lib/groonga_client_model/attribute_assignment.rb (+16 -25) 54% =================================================================== --- lib/groonga-client-model.rb 2016-12-27 14:43:00 +0900 (c2cad11) +++ lib/groonga_client_model/attribute_assignment.rb 2016-12-27 15:08:10 +0900 (58f4141) @@ -14,30 +14,21 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "active_model" - -require "groonga/client" - -require "groonga_client_model/version" - -require "groonga_client_model/client" -require "groonga_client_model/client_opener" -require "groonga_client_model/error" -require "groonga_client_model/load_value_generator" -require "groonga_client_model/modelizable" -require "groonga_client_model/modelize" -require "groonga_client_model/record" -require "groonga_client_model/schema" -require "groonga_client_model/schema_loader" - module GroongaClientModel - extend ActiveSupport::Autoload - - mattr_accessor :logger, instance_writer: false -end - -ActiveSupport.run_load_hooks(:groonga_client_model, GroongaClientModel) - -if defined?(Rails) - require "groonga_client_model/railtie" + module AttributeAssignment + if ActiveModel.const_defined?(:AttributeAssignment) + include ActiveModel::AttributeAssignment + else + def assign_attributes(attributes) + attributes.each do |name, value| + setter = "#{name}=" + if respond_to?(setter) + public_send(setter, value) + else + raise NoMethodError, "unknown attribute: #{name}: #{self.class}" + end + end + end + end + end end Modified: lib/groonga_client_model/record.rb (+1 -1) =================================================================== --- lib/groonga_client_model/record.rb 2016-12-27 14:43:00 +0900 (65e6200) +++ lib/groonga_client_model/record.rb 2016-12-27 15:08:10 +0900 (9749e58) @@ -16,7 +16,7 @@ module GroongaClientModel class Record - include ActiveModel::AttributeAssignment + include AttributeAssignment include ActiveModel::AttributeMethods include ActiveModel::Callbacks include ActiveModel::Conversion -------------- next part -------------- HTML����������������������������... ダウンロード